[Pharo-project] [squeak-dev] Compiler pedantic about ifNotNil:
argument
Levente Uzonyi
leves at elte.hu
Sun Oct 10 14:55:20 UTC 2010
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
>
> Please don't add so much dwimmery here. I like it that Smalltalk is
> fairly strict with these basic forms.
>
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
> <merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
> Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
> See http://methodsandmessages.posterous.com/ for Smalltalk discussion
>
> _______________________________________________
> Pharo-project mailing list
> Pharo-project at lists.gforge.inria.fr
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
More information about the Squeak-dev
mailing list
|