[OT] Writing a parser for BASIC in Smalltalk/Squeak ?

Hans-Martin Mosner hmm at heeg.de
Thu Jan 10 10:24:52 UTC 2002


Tim Rowledge wrote:
> 
> Sorry guys, but by inspection, deduction, induction, reductio ad
> absurdum, bivariant algorithmic analysis, flim-flam and fiat, you are
> wrong. So there. {raspberry sound effects}
> 
> Expressions in () are supposed to be _completed_ before the rest of the
> expression is executed.
Tim, I really hold you in high regard, but this is utter nonsense.
Message receivers and arguments are evaluated left-to-right, after applying the precedence rules and parenthesizing.
Parenthesizing does not mean that parenthesized expressions standing to the right of unparenthesized expressions are evaluated first.
In the case of 'm + (m := n)' every sane Smalltalk (Squeak included) does this:
1. compute m (the receiver of #+)
2. compute m := n (the argument to #+). This breaks down into
   2.1. compute n
   2.2. assign that value to m
   (the assigned value is now the result of step 2)
3. send #+ to the result of step 1, with the result of step 2 as the argument.

Unlike C, which has no defined evaluation order (at least K&R C doesn't), Smalltalk has a very simple and absolutely beautiful set of rules regarding parsing and evaluation.

Cheers,
Hans-Martin




More information about the Squeak-dev mailing list