|
From: | Paolo Bonzini |
Subject: | Re: [Help-smalltalk] short list of possible smalltalk extensions |
Date: | Sun, 05 Dec 2010 13:18:42 +0100 |
User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101103 Fedora/1.0-0.33.b2pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.6 |
On 12/05/2010 01:14 PM, Dmitry Matveev wrote:
Hello,5.a) Anonymous variables for blocks. x select: [ _ even]As far as I know, the latest VisualWorks support another way to do it: x select: #even I.e. pass a selector symbol, not a block. Just FYI :)
Yes, this is a fairly common extension but it has problems because "#even numArgs" is 0 while "[:a | a even ] numArgs" is one. This is the main reason why GNU Smalltalk does _not_ provide Symbol>>#value (and never will).
However, in my message there's also an alternative way to provide "x select: #even" by tweaking the meaning of #select:'s argument.
BTW, "x select: #even" needs to use reflection so it will always be slower than "x select: [ :a | a even]", especially when using a JIT compiler.
Paolo
[Prev in Thread] | Current Thread | [Next in Thread] |