Fear and loathing of the "perification" of Smalltalk

Peter William Lount peter at smalltalk.org
Tue Sep 4 23:01:08 UTC 2007


Damien Pollet wrote:
> On 04/09/07, Bert Freudenberg <bert at freudenbergs.de> wrote:
>   
>>>>     "Same as using curly braces but importantly NO syntax changes
>>>> needed!"
>>>>     list := [a. b. c] objects.
>>>>         
>>> But  a. b. c  is a sequence that evaluates to the result of c. How can
>>> the block see a and b without doing dirty tricks accessing its own
>>> source code ?
>>>       
>> "[a. b. c]" is just a block defining a sequence of statements. The
>> value depends on how you evaluate that block - sending #value only
>> retains the last value, but you could as well define another
>> evaluation strategy by sending another message.
>>     
>
> But that involves VM and semantics changes that are far more heavier
> than just adding syntactic sugar... 
No, the changes wouldn't be any more complex than what was done for 
curly braces except for adding the parameterization of the passing in of 
the collection that you want the results to flow into (including streams).
> To me a. b. c really means "evaluate a then b then c and return the result of c". 
For normal default evaluation yes.

> If you change that then you have to
>  - explain that period has different semantics depending on the context (*),
>   
Nope. Period has exactly the same semantics. That doesn't change. It's 
the evaluator that changes by collecting up all the results of 
statements rather than just returning the last statement's result.

>  - make it possible to define new evaluation semantics for blocs (why
> two and not more)
>   
Yes, an excellent point. If you can think of another evaluator why not? 
Yes, this should be parameterized, however this might have to happen at 
the virtual machine level for performance reasons.

>  - fix the block optimisations, because now they are just sequences of
> expressions with undefined a-priori semantics
>   
Could you illuminate more on this, I'm not sure what you mean.

> etc etc etc
>
> (*) just on this point I'd prefer to write something like
> {[a]. [:x| x b]. [:x | x c]} valueAsChain
>
>   
What would this evaluate as and how would it evaluate? Would each 
element of the collection be evaluated as a block and passed in the 
value from the previous element? Otherwise where would the subsequent 
block get their values?

Peter




More information about the Squeak-dev mailing list