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

_______________________________________________
help-smalltalk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to