[squeak-dev] Block argument syntax

Levente Uzonyi leves at elte.hu
Fri Mar 1 23:20:38 UTC 2013


On Fri, 1 Mar 2013, Bert Freudenberg wrote:

>
> On 2013-03-01, at 16:48, Chris Muller <asqueaker at gmail.com> wrote:
>
>>> I know this is true for a number of Smalltalk implementations.  I found it
>>> very surprising also.  Someone I worked with always formatted their code
>>> this way.  He said it made it easier to double click and highlight the
>>> variable.  I wasn't sure that was enough reason to do it but he did.
>>
>> So, score +1 for ": x" but ":x" is still left with a score of 0.  What
>> is the advantage of writing ":x"?
>
> One char less. Better visual grouping of multiple arguments.
>
> (1) [:a :b|a+b]
> (2) [:a :b | a + b]
> (3) [ :a :b | a + b ]
> (4) [ : a : b | a + b ]
>
> In my eyes, (2) is the best compromise between conciseness and readability.

I prefer (3), but (4) doesn't look bad either. (1) and (2) are less 
readable for me.

It's funny that one can't write [:a:b|a+b], because the parser expects a 
white space after the argument name.


Levente

>
> - Bert -
>
>
>
>


More information about the Squeak-dev mailing list