[Cuis-dev] unnecessary punctuation

Martin McClure martin at hand2mouse.com
Fri Jun 14 16:33:32 PDT 2024


On 6/14/24 05:24, Jaromir Matas via Cuis-dev wrote:
> And back to the original Mark's question (roughly) - why would it be 
> bad to modify the compiler so that
>
> `cond ifTrue: a ifFalse: b`
>
> is treated the same way as
>
> `cond ifTrue: [a] ifFalse: [b]`
>
> i.e. optimized using bytecode jumps rather than sending 
> #ifTrue:ifFalse: ?

This would be a major change to the semantics of Smalltalk.
Consider that a and b are arbitrary expressions.

   cond ifTrue: [a] ifFalse: [b]

evaluates at most one of the expressions, while

   cond ifTrue: a ifFalse: b

by Smalltalk evaluation rules evaluates a, then b, then sends 
ifTrue:ifFalse:.

Smalltalk has a very simple syntax that relates directly to simple 
message-sending and assignment semantics. Very easy to understand. 
Changing the compiler to use bytecode jumps in the latter case would 
badly undermine this simplicity.

Regards,
-Martin


More information about the Cuis-dev mailing list