Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!europa.eng.gtefsd.com!howland.reston.ans.net!math.ohio-state.edu!jussieu.fr!news.oleane.net!oleane!pipex!bnr.co.uk!bcarh8ac.bnr.ca!bcarh189.bnr.ca!nott!torn!news.unb.ca!coranto.ucs.mun.ca!nstn.ns.ca!dragon.acadiau.ca!car407.acadiau.ca!ivan
From: ivan@ace.acadiau.ca (IVAN TOMEK)
Subject: Re: Evaluation order - correction
Message-ID: <ivan.73.2F32350B@ace.acadiau.ca>
Lines: 72
Sender: news@relay.acadiau.ca
Nntp-Posting-Host: car407.acadiau.ca
Organization: Acadia University
X-Newsreader: Trumpet for Windows [Version 1.0 Rev B final beta #1]
References: <sf2cef6f.007@BYUH.EDU> <3gmobl$7hf@acsnews.uswc.uswest.com>
Date: Fri, 3 Feb 1995 13:52:11 GMT
Lines: 72

In article <3gmobl$7hf@acsnews.uswc.uswest.com> martin@is.com (Martin McClure) writes:

>In article <sf2cef6f.007@BYUH.EDU>  Chris Jones writes:
>> Question:  What is the true order of expression evaluation in  
>Smalltalk/V?
>> 

><...> 

>> Example:  1 + 2 +3 factorial
>> Evaluates:  (1 + 2) + 3 factorial
>> 
>> Rather than:  1 + 2 + (3 factorial) as suggested in the Digitalk Manual.
>> 

><...>

>> Christopher G. Jones
>> Associate Professor of Information Systems
>> Brigham Young University - Hawaii Campus
>> internet:   jonesc@BYUH.edu
>> compuserve: 75320,3105

>Interesting point. I don't have a running /V system handy, but in VW2.0 I  
>tried compiling

>   self halt.
>   1 + 2 + 3 factorial.

>and got this compiled method:

>   normal CompiledMethod numArgs=0 numTemps=0 frameSize=12

>   literals: (#halt #factorial )

>   1 <44> push self
>   2 <CD 00> non-immediate send halt
>   4 <66> pop
>   5 <4A> push 1
>   6 <4B> push 2
>   7 <DF 00> no-check send +
>   9 <D8 03> push 3
>   11 <CC 01> no-check send factorial
>   13 <A0> send +
>   14 <65> return

>Or, in postfix (ignoring the halt, which was for convenience), 
>"1 2 + 3 factorial +"

>I tried compiling "1 + 2 + (3 factorial)." and "(1 + 2) + 3 factorial."  
>and got the very same compiled code, no difference in order of evaluation.  
>Single stepping through with the debugger confirmed the compiled code's  
>order. Just to get something that would *have* to be different, I compiled  
>"1 + (2 + 3) factorial", which resulted in a postfix equivalent of 
>"1 2 3 factorial + +".

>-Martin McClure
>the 
>Not an Official Spokesperson 
>of
>Integrity Solutions
>St Paul, MN


Correction of an apparent typing mistake:
The expression 1 + (2 + 3) factorial 
gives 1 2 3 + factorial + as you can see when you <inspect> the<method> object 
under the <unboundMethod> in the debugger. This, of course, produces the 
expected result.

Ivan Tomek

