Some Self ideas

Lex Spoon lex at cc.gatech.edu
Fri Jan 19 23:28:39 UTC 2001


> 
> >	5) Readability again. My eyes catch the [].
> 
> And what does the [] tell you?
> A - That you have encountered one of those idiosyncratic messages, #ifTrue:#ifFalse:, which happens to be a bit peculiar as to what kind of arguments it will accept and how they are written?
> B - That the programmer has decided to defer evaluation of the code within until such time as it is really needed?
> C - Something else?
> 
> My eyes translate the [] as B. Unnecessary brackets do as little for readability in my eyes as unnecessary parentheses. I would prefer the brackets to mean: "Don't evaluate this code right now. just package it up so that it can be evaluated later, if need be."
> 

To be pedantic, this is precisely what the [] *does* mean in
ifTrue:ifFalse: -- the code is packaged up and is possibly evaluated
later.

Agreed that it's kind of annoying to be explicit about things like that,
but it *is* what's going on.



> 
> >		cond ifTrue: 1->2 ifFalse: 2->2
> >	would return 2 in both cases!
> 
> Well, it basically does that now.

The point is, when you start, it looks so cool being able to do this:

	cond ifTrue: 2 ifFalse: 3

but the idiom breaks down into the general case very quickly, and it's
not even a clean break -- there are plenty of border cases for people to
get snagged on.  The above is one of them, and I'd hate trying to
explain to a newbie what was happening.



-Lex





More information about the Squeak-dev mailing list