On Sun, 10 Oct 2010, Randal L. Schwartz wrote:

"Igor" == Igor Stasenko <[email protected]> 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
<[email protected]> <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
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to