[Q] Is a vertical bar necessary in block?

Glenn Krasner krasner at objectshare.com
Mon May 17 17:36:08 UTC 1999


As I recall, the vertical bar was required because it looked right. It was
a nice separator between the arguments and statements, and the same
separator used in methods for temps. This separator seemed more necessary
for blocks than methods because blocks were more often on one line, while
methods typically were multi-line so the vertical space provided the
separation, and because the colon was only a tiny indication of an
argument, while a method had whole keywords. At the time, it was
unambiguous because there were no block temps.

It couldn't be applied to methods because of the same ambiguities with "!"
as a binary message that blocks run into (how do you parse "foo | a | 3",
is "a" a temp or the receiver of the "| 3" message?), but it was ok at the
time to apply this rule only to blocks.

Removing the requirement would not only make blocks and methods parse the
same, but would let blocks have temps without the double vertical bar (the
now-ANSI solution to the above ambiguity). But you'd lose the separation
(and have a backward compatibility issue).

glenn

At 02:12 PM 5/15/99 +0200, you wrote:
>Folks,
>
>I was wondering why the vertical bar is necessary in a block.
>
>I consider a block to be an unnamed method where each colon in a block
>denotes a parameter just as in a normal method.
>
>[ : a : b ] could be viewed as a method with selector :: (colon-colon).
>
>Just as in a method the vertical bar is not necessary, this bar could be
>dropped from the block syntax.
>
>I patched the parser (see below) to ignore the absence of a vertical bar and
>as far as I can see things still compile correctly.
>
>So, my first question is: Is there any (compelling) reason for the vertical
>bar in the block syntax?
<snip>
>Reinier.
>





More information about the Squeak-dev mailing list