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

Florin Mateoc fmateoc at gmail.com
Sun Oct 10 16:30:07 UTC 2010


 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.
Sugar is bad for you in your food, let's be conservative with it in our language as well.
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

Florin



More information about the Squeak-dev mailing list