[haXe] blocks and yield?
Nicolas Cannasse
ncannasse at motion-twin.com
Sat Apr 7 10:10:25 CEST 2007
> java doesn't have a yield in the vm either (as far as i know), but
> groovy does it like this
>
> public method(int x,Closure c) {
> // snip
> c.call(myparam);
> // snip
> }
>
> called with
>
> obj.method(1) { p ->
> println p
> }
>
> OR
>
> obj.method(1,{p-> println p})
This is only a "local" yield, so less powerful, since you can't escape
the scope of the Closure.
It can be done currently in haXe :
public function method( x, f ) {
// snip
f(456);
// snip
}
obj.method(1,function(p) { trace(p); });
So your proposal is mainly about having another syntax of function
parameters, which would save only a few chars (the 'function' keyword).
I'm not sure then it's worth adding a specific syntax for that.
Nicolas
More information about the Haxe
mailing list