From: Joerg Hoehle
Subject: setf evaluation order?
Date: 
Message-ID: <uekg0tata.fsf@users.sourceforge.net>
Hi,

is there a mandated evaluation order for SETF?

I would naively have expected left to right order to generally apply,
even when places are involved, yet CLISP 2.33 and CormanLisp 2.0 yield
different results for the following:

(let ((v (vector 'a 'b 'c)) (i 0))
  (setf (aref v (incf i)) (incf i)) v)

clisp:  #(A 2 C), i.e. left to right
Corman: #(A B 1), i.e. value first, then place

Are both behaviours covered by the standard or is one in error?

Thanks for your help,
	Jorg Hohle
Telekom/T-Systems Technology Center

From: Sam Steingold
Subject: Re: setf evaluation order?
Date: 
Message-ID: <uk6psrv89.fsf@gnu.org>
> * Joerg Hoehle <······@hfref.fbheprsbetr.arg> [2005-02-01 19:05:53 +0100]:
>
> is there a mandated evaluation order for SETF?

yes: <http://www.lisp.org/HyperSpec/Body/sec_5-1-1-1.html>

(also <http://www.lisp.org/HyperSpec/Body/sec_5-1-2-9.html>:
 see comment "force correct order of evaluation")

> I would naively have expected left to right order to generally apply,
> even when places are involved, yet CLISP 2.33 and CormanLisp 2.0 yield
> different results for the following:
>
> (let ((v (vector 'a 'b 'c)) (i 0))
>   (setf (aref v (incf i)) (incf i)) v)
>
> clisp:  #(A 2 C), i.e. left to right
right

> Corman: #(A B 1), i.e. value first, then place
wrong.

> Are both behaviours covered by the standard or is one in error?

CLISP (and LW) is right.
Corman is wrong.

-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.honestreporting.com>
non-smoking section in a restaurant == non-peeing section in a swimming pool
From: Peter Seibel
Subject: Re: setf evaluation order?
Date: 
Message-ID: <m3y8e8jf4n.fsf@javamonkey.com>
Joerg Hoehle <······@users.sourceforge.net> writes:

> Hi,
>
> is there a mandated evaluation order for SETF?
>
> I would naively have expected left to right order to generally apply,
> even when places are involved, yet CLISP 2.33 and CormanLisp 2.0 yield
> different results for the following:
>
> (let ((v (vector 'a 'b 'c)) (i 0))
>   (setf (aref v (incf i)) (incf i)) v)
>
> clisp:  #(A 2 C), i.e. left to right
> Corman: #(A B 1), i.e. value first, then place
>
> Are both behaviours covered by the standard or is one in error?

In Section 5.1.1 it talks about the macro expansion of a SETF form
guaranteeing "left-to-right evaluation of subforms". I assume that's
talking about the subforms of the SETF form in which case CLISP is
conformant and Corman is not. But I could well be missing something.

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp
From: Kent M Pitman
Subject: Re: setf evaluation order?
Date: 
Message-ID: <ulla7v60f.fsf@nhplace.com>
[Hi, guys.  I was configuring my newsreader after months of disuse and
 happened upon this one, which I figured was as good as any to test my
 posting capability with...]
 
Peter Seibel <·····@javamonkey.com> writes:

> Joerg Hoehle <······@users.sourceforge.net> writes:
> 
> > Hi,
> >
> > is there a mandated evaluation order for SETF?
> >
> > I would naively have expected left to right order to generally apply,
> > even when places are involved,

Yes, this is the entire point of the hair related to SETF expanders
(see GET-SETF-EXPANSION and DEFINE-SETF-EXPANDER).  If we hadn't cared
about such matters, the language definition would have been smaller
(and programs correspondingly less predictable).

> > yet CLISP 2.33 and CormanLisp 2.0 yield different results for the
> > following:
> >
> > (let ((v (vector 'a 'b 'c)) (i 0))
> >   (setf (aref v (incf i)) (incf i)) v)
> >
> > clisp:  #(A 2 C), i.e. left to right
> > Corman: #(A B 1), i.e. value first, then place
> >
> > Are both behaviours covered by the standard or is one in error?
> 
> In Section 5.1.1 it talks about the macro expansion of a SETF form
> guaranteeing "left-to-right evaluation of subforms". I assume that's
> talking about the subforms of the SETF form in which case CLISP is
> conformant and Corman is not. But I could well be missing something.

I concur, FWIW.  Not that any of our individual words on the matter
is anything other than just a personal opinion...

I always hesitate (in part because ANSI warned us at the first ANSI CL
standards meeting that it could lead to defamation lawsuits) to say
directly that someone's implementation is definitely wrong.   So instead
I'll just comment indirectly by quoting George C. Scott as General Turgidson
from _Dr. Strangelove_ when he said to the US President:

  That's right, sir, you are the only person authorized to do so.
  And although I, uh, hate to judge before all the facts are in, 
  it's beginning to look like, uh, General Ripper exceeded his authority.   

Now, I _suppose_ one could argue that since I wrote
  "the subforms of place1 and value1 are evaluated,"
and not
  "the subforms of place1 are first evaluated, 
   then the form value1 is evaluated,
   and then ..."
that what I meant was:
  "the subforms of place1 are evaluated left-to-right and the
   entire form value1 is evaluated (using normal left-to-right rules,
   since it's a normal form), but value1 might be evaluated before value2"
but _really_, after laboring over the importance of preserving left
to right evaluation for page after page, showing how we're working to
preserve it at high cost, is it really a likely reading that we would 
suddenly abandon it without highlighting the reason?

Again yielding to metaphor, I'll quote Sir Thomas More [somewhat out 
of context--I don't think he was a Lisp programmer] in 
A Man for All Seasons:

   "Is it probable--is it probable--that after so long a silence
    on this, the very point so urgently sought of me, I should 
    open my mind to such a man as that?"

The mood, if not the topic matter, seemed somehow apropos.
(It's a highly worthy play and movie, btw.  The movie is on my 
personal "top 10" list.  See it if you have not.)

Have a good day, all.
 --Kent
From: Duane Rettig
Subject: Re: setf evaluation order?
Date: 
Message-ID: <4hdkv8odl.fsf@franz.com>
[OT]:

Kent M Pitman <······@nhplace.com> writes:

> [Hi, guys.  I was configuring my newsreader after months of disuse and
>  happened upon this one, which I figured was as good as any to test my
>  posting capability with...]

Hey, Kent!  Welcome back!

-- 
Duane Rettig    ·····@franz.com    Franz Inc.  http://www.franz.com/
555 12th St., Suite 1450               http://www.555citycenter.com/
Oakland, Ca. 94607        Phone: (510) 452-2000; Fax: (510) 452-0182   
From: Kenny Tilton
Subject: Re: setf evaluation order?
Date: 
Message-ID: <_q_Ld.77966$ld2.26129570@twister.nyc.rr.com>
Duane Rettig wrote:
> [OT]:
> 
> Kent M Pitman <······@nhplace.com> writes:
> 
> 
>>[Hi, guys.  I was configuring my newsreader after months of disuse and
>> happened upon this one, which I figured was as good as any to test my
>> posting capability with...]
> 
> 
> Hey, Kent!  Welcome back!
> 

Yes. Welcome back. You won't recognize the joint. :)

kt

-- 
Cells? Cello? Cells-Gtk?: http://www.common-lisp.net/project/cells/
Why Lisp? http://lisp.tech.coop/RtL%20Highlight%20Film

"Doctor, I wrestled with reality for forty years, and I am happy to 
state that I finally won out over it." -- Elwood P. Dowd
From: Pascal Costanza
Subject: Re: setf evaluation order?
Date: 
Message-ID: <ctq9hp$mjc$1@snic.vub.ac.be>
Duane Rettig wrote:
> [OT]:
> 
> Kent M Pitman <······@nhplace.com> writes:
> 
>>[Hi, guys.  I was configuring my newsreader after months of disuse and
>> happened upon this one, which I figured was as good as any to test my
>> posting capability with...]
> 
> Hey, Kent!  Welcome back!

Seconded! ;)


Pascal
From: Bulent Murtezaoglu
Subject: Re: setf evaluation order?
Date: 
Message-ID: <871xbzhvsc.fsf@p4.internal>
>>>>> "PS" == Pascal Costanza <··@p-cos.net> writes:

    PS> Duane Rettig wrote:
    >> [OT]: Kent M Pitman <······@nhplace.com> writes:
    >> 
    >>> [Hi, guys.  I was configuring my newsreader after months of
    >>> disuse and happened upon this one, which I figured was as good
    >>> as any to test my posting capability with...]
    >> Hey, Kent!  Welcome back!

    PS> Seconded! ;)

Nth'ed.  Perhaps it worth noting that when experienced people exhibit 
AOLer-ish "me too" behaviour on reappearence of someone, it must be 
the usenet equivalent of recognizing his community service.  

cheers,

BM
From: Marco Antoniotti
Subject: Re: setf evaluation order?
Date: 
Message-ID: <c77Md.12$fp1.25600@typhoon.nyu.edu>
Good to see you again.

Marco



Kent M Pitman wrote:
> [Hi, guys.  I was configuring my newsreader after months of disuse and
>  happened upon this one, which I figured was as good as any to test my
>  posting capability with...]
>  
> Peter Seibel <·····@javamonkey.com> writes:
> 
> 
>>Joerg Hoehle <······@users.sourceforge.net> writes:
>>
>>
>>>Hi,
>>>
>>>is there a mandated evaluation order for SETF?
>>>
>>>I would naively have expected left to right order to generally apply,
>>>even when places are involved,
> 
> 
> Yes, this is the entire point of the hair related to SETF expanders
> (see GET-SETF-EXPANSION and DEFINE-SETF-EXPANDER).  If we hadn't cared
> about such matters, the language definition would have been smaller
> (and programs correspondingly less predictable).
> 
> 
>>>yet CLISP 2.33 and CormanLisp 2.0 yield different results for the
>>>following:
>>>
>>>(let ((v (vector 'a 'b 'c)) (i 0))
>>>  (setf (aref v (incf i)) (incf i)) v)
>>>
>>>clisp:  #(A 2 C), i.e. left to right
>>>Corman: #(A B 1), i.e. value first, then place
>>>
>>>Are both behaviours covered by the standard or is one in error?
>>
>>In Section 5.1.1 it talks about the macro expansion of a SETF form
>>guaranteeing "left-to-right evaluation of subforms". I assume that's
>>talking about the subforms of the SETF form in which case CLISP is
>>conformant and Corman is not. But I could well be missing something.
> 
> 
> I concur, FWIW.  Not that any of our individual words on the matter
> is anything other than just a personal opinion...
> 
> I always hesitate (in part because ANSI warned us at the first ANSI CL
> standards meeting that it could lead to defamation lawsuits) to say
> directly that someone's implementation is definitely wrong.   So instead
> I'll just comment indirectly by quoting George C. Scott as General Turgidson
> from _Dr. Strangelove_ when he said to the US President:
> 
>   That's right, sir, you are the only person authorized to do so.
>   And although I, uh, hate to judge before all the facts are in, 
>   it's beginning to look like, uh, General Ripper exceeded his authority.   
> 
> Now, I _suppose_ one could argue that since I wrote
>   "the subforms of place1 and value1 are evaluated,"
> and not
>   "the subforms of place1 are first evaluated, 
>    then the form value1 is evaluated,
>    and then ..."
> that what I meant was:
>   "the subforms of place1 are evaluated left-to-right and the
>    entire form value1 is evaluated (using normal left-to-right rules,
>    since it's a normal form), but value1 might be evaluated before value2"
> but _really_, after laboring over the importance of preserving left
> to right evaluation for page after page, showing how we're working to
> preserve it at high cost, is it really a likely reading that we would 
> suddenly abandon it without highlighting the reason?
> 
> Again yielding to metaphor, I'll quote Sir Thomas More [somewhat out 
> of context--I don't think he was a Lisp programmer] in 
> A Man for All Seasons:
> 
>    "Is it probable--is it probable--that after so long a silence
>     on this, the very point so urgently sought of me, I should 
>     open my mind to such a man as that?"
> 
> The mood, if not the topic matter, seemed somehow apropos.
> (It's a highly worthy play and movie, btw.  The movie is on my 
> personal "top 10" list.  See it if you have not.)
> 
> Have a good day, all.
>  --Kent
From: Rahul Jain
Subject: Re: setf evaluation order?
Date: 
Message-ID: <878y63pvob.fsf@nyct.net>
Kent M Pitman <······@nhplace.com> writes:

> [Hi, guys.  I was configuring my newsreader after months of disuse and
>  happened upon this one, which I figured was as good as any to test my
>  posting capability with...]

Welcome back! Looking forward to reading your posts again!

-- 
Rahul Jain
·····@nyct.net
Professional Software Developer, Amateur Quantum Mechanicist