Eliminating assignments and variable syntax (accessors)

Bijan Parsia bparsia at email.unc.edu
Thu Aug 12 12:48:37 UTC 1999

At 10:55 PM -0400 8/11/99, Lex Spoon wrote:

>Well, it's certainly open to discussion :)  I'd think it best to count the
>first indent as just part of method definition.  So to get a block inside a
>method, you'd have to add *another* indentation, like this:
>	myMethod
>		| x y z |
>			x := 1
>			y := 2
>			z := 3

Blargh! That's gross! Imagine the errors! You can't *tell*, without a
comment, whether this is a misindentation or a block. *Silent*, *SEMANTIC*
errors due to copy and paste are evil. Python doesn't have *that* problem.

I *think* that *mere* indentation doesn't generate a new block in python.
Indendation replaces the role of braces in C or begin...end in Pascal--you
have *keywords* indicating *what sort* of block you're dealing with
(neither has closures, even ersatz ones, so this problem doesn't crop up).
And, IIRC, you have a *colon* marking the start, e.g.,:

def foo(bar):
	if bar == 3:
		return bar
		return bar * 10

So, really, the opening delimiter of a block is something like *colon*
newline, rather than just new line. (I get bit by this all the time!)

>This syntax also works out fine for storing a block into a variable:
>	myMethod
>		| b x y |
>		b :=
>			x := 1
>			y := 2
>		^b
>It doesn't *look* real nice, but the fact that it's different is surely a
>big contributor.

However big a contributer it may be, it's contribution is *totally* swamped
by the contribution of the intrinsic butt-ugliness of it :) Ugh. Espeically
with the caret making the "b"s visually misalign!

>Unfortunately, as you point out, it's tricky to send a message directly to
>a block.  Hadn't thought about that one...  Tough tough tough....  Maybe it
>would be worth living without this ability, just to have a syntax that is
>easier to scan through?

Maybe...but this syntax *isn't* easier to scan through!


>Well, I for one am not yet convinced, but it still seems like a neat idea.
>For languages with lots of control structure, like Python, the code comes
>out looking *really* elegant.

I don't know about *elegant*. It surely comes out *consistent* which is
nice. I find Python rather syntax heavy and the main advantage of the
whitespace stuff is to lighten it a bit (since in *any* language, if you're
sane, you'll use whitespace & indentation to pragamtically indicate block
structure; Python merely turns the pragmatics into syntax, which has some

I know other langauges use whitespace "Pythonically" (ML? Icon?) but I have
little to no experience with them.

>  But is it useful in a language like Smalltalk, where blocks are so
>important and where there is next to nil syntax?

No. :) I'd say it's not useful in Lispy languages either, where indentation
plays a huge pragmatic role. I *don't* like the idea, for example, of
*eliminanting* the parens in an outlining editor (as some have done).
Rather *augmenting* them seems more sensible.


More information about the Squeak-dev mailing list