Newbie question

Bert Freudenberg bert at freudenbergs.de
Mon Jul 23 18:09:38 UTC 2007


On Jul 23, 2007, at 19:59 , Ramon Leon wrote:

>> The period is really a separator and not an operator. Since
>> period is also used as a decimal point, one needs to watch
>> out for gotchas like:
>>  {1.2.3} = an array with two elements 1.2 and 3
>>  {1 . 2 . 3} = an array with three elements 1, 2 and 3
>>
>> I wonder how period came to be used as a separator within
>> braces in Smalltalk instead of comma or semicolon.
>>
>> Regards .. Subbu
>
> This isn't common to all Smalltalks, it's a Squeak idiom as far as  
> I know,
> though others may have some form of literal array as well.  It also  
> makes
> perfect sense to use a period, since the period is "the" statement  
> seperator
> for expressions in Smalltalk.

Right - just like a block it evaluates all statements in turn,  
separated by periods. But whereas a block returns the result of the  
last statement, the brace construct collects all results and returns  
them as an array.

Now, at one point the compiler even supported this:

	{a. b} := {1. 2}

which I found cool but was considered evil, even by those who  
tolerate the braces ...

- Bert -





More information about the Squeak-dev mailing list