[haXe] blocks and yield?

blackdog blackdog at ipowerhouse.com
Fri Apr 6 12:40:11 CEST 2007


hi list

It'd be nice to have the rubyish block and yield construct in haxe,
it's just a bit of 'syntactic sugar' as it seems to me all the
requisite plumbing exists.

obj.method() { x -> block }

inside method

..

yield x

..

this is exactly the same as 

obj.method( ..., f->x:Dynamic->Void)

inside method

..

f(x)
..

In groovy this is exactly all they do. They simply replace the final
parameter of the method call with the given block if it exists and then
within the method use f.call(x). Since the groovy/haxe syntaxes are
similar it's something that is working in practice in a C type braced
language.  It would make the verbose anonymous function definition
in iterables easier to read and use. 

IMHO haxe is different enough from JS to warrant it - and i think it
would increase it's cool factor with the ruby crowd - and indeed draw
converts as haxe type inference is superior as long the ease of
use/readability exists.

I think this is easy low hanging fruit for Nicolas :) and haxe as the
NBL!

bd



More information about the Haxe mailing list