Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!oitnews.harvard.edu!purdue!lerc.nasa.gov!magnus.acs.ohio-state.edu!math.ohio-state.edu!news.cyberstore.ca!vanbc.wimsey.com!unixg.ubc.ca!news.bc.net!newsserver.sfu.ca!fornax!cs.sfu.ca!serge
From: serge@cs.sfu.ca (Serge Le Huitouze)
Subject: Re: setarg/3 (Was: speed of prolog)
In-Reply-To: kish@cs.man.ac.uk's message of 20 Jun 1995 01:56:08 GMT
Message-ID: <SERGE.95Jun21164240@maroilles.cs.sfu.ca>
Sender: news@cs.sfu.ca
Organization: School of Computing Science, Simon Fraser University
References: <THOMASL.95Jun13172908@arnold.csd.uu.se>
	<SERGE.95Jun16150840@maroilles.cs.sfu.ca>
	<KISH.95Jun18033252@rdf035.cs.man.ac.uk>
	<SERGE.95Jun19153749@maroilles.cs.sfu.ca>
	<KISH.95Jun20025608@rdf035.cs.man.ac.uk>
Date: 21 Jun 1995 23:42:40 GMT
Lines: 42



 > >Instead of "T = f(X)", let's have "T = f(1)", or "T = f(g(X))".
 >
 > >Do you think that 33 should be the same entity as 1 or g(X), after the
 > >call to 'setarg/3' ?
 >
 > No, but these are instantiated terms. setarg/3 is of course
 > non-logical. However, I would still expect a logical variable (X in your
 > original example), bound to an argument, to track the changes in that
 > argument. 
 >
 > --Kish Shen

OK, so what would you expect in the following cases ?

%| ?- [user].
%foo1(R) :- T = f(X), X = something, setarg(1,T,33), R=result(T,X).
%foo2(R) :- X = something, T = f(X), setarg(1,T,33), R=result(T,X).

In these two cases, I think one could say that X is bound to the first
argument of T, right ?

However, one works, the other doesn't:

%| ?- foo1(R1), foo2(R2).
%
%R1 = result(f(33),33)
%R2 = result(f(33),something)
%yes

If you read the SICSTUS manual, you'll find:
"This operation is only safe if there is no further use of the ``old''
value of the replaced argument".

I still have hard time understanding this definition :-)

Coming back to my initial point, I just disagreed in proposing using
'setarg/3' to solve the general problem of assignment in Prolog, given its
bogus nature.

--Serge
