[haXe] blocks and yield?
Bent Rasmussen
incredibleshrinkingsphere at gmail.com
Sun Apr 8 00:02:58 CEST 2007
Well, a shorter inline function syntax would be nice. But it has to be nice
as well! ;-)
And nice is not a sufficient reason for Nicolas. hehe
----- Original Message -----
From: "blackdog" <blackdog at ipowerhouse.com>
To: <haxe at lists.motion-twin.com>
Sent: Saturday, April 07, 2007 3:52 PM
Subject: Re: [haXe] blocks and yield?
> On Sat, 07 Apr 2007 10:10:25 +0200
> Nicolas Cannasse <ncannasse at motion-twin.com> wrote:
>
>> > 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
>>
>>
>
> Hi Nicolas
>
> Yes, it's only syntactic sugar as i mentioned. Disclaimer, I'm not a
> language lawyer :), but I use groovy for my server side stuff and,
> subjectively, the removal of the function definition is very welcome,
> it's cleaner and easier to read - and i think the groovy model proves
> that this is a useful workable tweak.
>
> Also, when I was learning ruby (and later groovy) my understanding of
> anonymous functions improved because of the ease of using this language
> construct. I tend to program more functionally in groovy cos it's
> clean, when i program functionally in javascript it gets messy - using
> the lambda module would be much nicer with this construct.
>
> Also if a client syntax could be agreed upon, then later in the
> evolution of the haxe language deeper mechanisms could be added like a
> non-local yield (whatever that is :)) , i.e. when you were ready you
> could do it properly. However, this method could be implemented in the
> other platforms haxe supports now.
>
> Anyone else got any comments on this ?
>
> On a side topic, I mentioned DSLs and builder functionality, but this
> depends on way to intercept and re-route a called method that doesn't
> exist on an object, which i guess is difficult with haxes typing - is
> this possible at all ?
>
> Thanks
>
> bd
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
More information about the Haxe
mailing list