[haXe] blocks and yield?

blackdog blackdog at ipowerhouse.com
Fri Apr 6 13:03:50 CEST 2007


On Fri, 6 Apr 2007 06:40:11 -0400
blackdog <blackdog at ipowerhouse.com> wrote:

> 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
> 

not to mention the ease of adding DSL's and builder functionality
(http://groovy.codehaus.org/Using+MarkupBuilder+for+Agile+XML+creation)
to haxe.

bd



More information about the Haxe mailing list