[Q] Is a vertical bar necessary in block?

Ranjan Bagchi ranjan.bagchi at pobox.com
Sat May 15 21:03:51 UTC 1999



> -----Original Message-----
> From: Peter William Lount [mailto:peter at smalltalk.org]
> Sent: Saturday, May 15, 1999 1:33 PM
> To: squeak at cs.uiuc.edu
> Subject: Re: [Q] Is a vertical bar necessary in block?
>
> [...]
> "Potential Cool Solution
> Why not name the parameters just like a keyword method? "
> aBlock := [length: a width: b | area | area := a * b. area].
>
> "or without the temporary variable"
> aBlock := [length: a width: b  a * b].
>
> "Like a keyword method but in block format (with the only real syntax
> difference being '[' and ']' surrounding the code). A single method object
> (which is what a block is) with no permanant (but temporary) variables!
> Activated via "
> 	anArea := aBlock length: 100 width: 50. "Easy to understand the
> parameters..."
>


I this this is a really neat idea.  Java has this with anonymous classes,
and I
think it does a lot for readability.

-rj





More information about the Squeak-dev mailing list