[OT] Writing a parser for BASIC in Smalltalk/Squeak ? (<CSOTD> included)

Richard A. O'Keefe ok at atlas.otago.ac.nz
Thu Jan 10 04:55:39 UTC 2002


Tim Rowledge <tim at sumeru.stanford.edu> wrote
originally that expressions in (...) should complete before
the rest of the expression in which they are embedded.
Someone else wrote:

	> I tried to find this in the ANSI spec, but I couldn't.  What references
	> did you use?

to which Tim Rowledge replied:

	My common sense in this case; admittedly this is something that my wife
	considers utterly atrophied but I feel quite strongly that a simple
	statement that acts in a completely surprising manner is a poor way to
	do things.

I've used a great many programming languages that allow assignments
embedded in expressions, starting with Burroughs Algol, and *none* of them,
not one, has used Tim Rowledge's rule.  Algol 68, APL, Burroughs Algol,
BCPL, C, Common Lisp, ...

"Common sense" usually arrives in the form of people responding to a
bug with "why didn't we think of that possibility before?", and the
usual responses include
 - banning embedded assignment (including Scheme's method of making the
   results of all kinds of assignment undefined), which of course leaves
   other embedded side effects intact;
 - leaving the effect of accessing a modified variable undefined
   (C makes certain guarantees about sequence points, and then leaves
   the rest undefined in this way; C programmers are allowed to do whatever
   they want, even if it's not what they want)
 - adopting a strict "left-to-right" rule, as Common Lisp does,
   or "strict left-to-right, allowing for operator precedence" as I
   understand newer versions of Erlang do (IIRC).

SqueakLint, should there be such an animal, should certainly warn about
expressions that access variables that they modify, but the general case
where these things are hidden behind method calls is impossible to detect.
For example,
    self x: (self x + self x: 2)
has the problem, and moving parenthesised stuff first will do NOTHING to
fix it.





More information about the Squeak-dev mailing list