[Pharo-project] [squeak-dev] Compiler pedantic about ifNotNil: argument

Levente Uzonyi leves at elte.hu
Sun Oct 10 17:15:25 UTC 2010


On Sun, 10 Oct 2010, Florin Mateoc wrote:

> On 10/10/2010 10:55 AM, Levente Uzonyi wrote:
>> On Sun, 10 Oct 2010, Randal L. Schwartz wrote:
>>
>>>>>>>> "Igor" == Igor Stasenko <siguctua at gmail.com> writes:
>>>
>>> Igor> i am also missing:
>>>
>>> Igor> someThing ifTrue: 1 ifFalse: 0
>>>
>>> Down that path lies ambiguity though.
>>>
>>> If you had
>>>
>>>  actionSymbol := aBoolean ifTrue: #doThis else: #doThat.
>>>
>>> do you want the symbol assigned, or performed?
>>
>> The implementation is staightforward IMHO.
>> If the receiver expects a niladic block, then the argument is returned. If the receiver can accept a niladic or a
>> monadic block, then #cull: is sent to the argument. If the receiver expects a monadic block, then #value: is sent to
>> the argument. This works perfercly with blocks.
>>
>> Keyword selector symbols are equivalent with monadic blocks in this case, so Symbol >> #cull: can be implemented as
>> ^argument perform: self. For other symbols #cull: is meaningless and #perform: will raise an error.
>>
>>
>> Levente
>>
>
> But the argument against it is not about implementation, it is about readability, that's where it introduces ambiguity
> and gratuitous incompatibility with other dialects.

I agree about readability when symbols are used where monadic blocks are 
not expected. I'm not sure about compatibility with other dialects. From 
Nicolas' mail I get that it's compatible with VW.

> Sugar is bad for you in your food, let's be conservative with it in our language as well.

It's not really sugar. This change allows these selectors to be used as 
any other selector.

> If all we want is to type less, we might as well drop keyword selectors (we could just have the colons) and use some
> kind of Hungarian notation (peace, Levente :) ) for identifiers

:)


Levente

>
> Florin
>
>



More information about the Squeak-dev mailing list