Experimental HSL version (needs feedback)

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Experimental HSL version (needs feedback)

Pimm Hogeling
Hi list,

I've been looking at macros and how they could improve the HSL experience. An experimental version of HSL, codenamed "orca", has been committed to the branches. I would like to hear from you, the haXe developers, what you think of this version.

Obviously, it's just a proof of concept. It's missing a lot of functionality. This will all be added.

So what changed, you ask. Basically, it's all about the syntax. In the current version of HSL, you'd write this:
    [...]
    ball.bouncedSignaler.bindVoid(playBounceSound);
}
private function playBounceSound():Void {
    [...]
}
With orca, you'd write this:
    [...]
    Binder.bind(ball.bouncedSignaler, playBounceSound);
}
private function playBounceSound():Void {
    [...]
}

In the current version of HSL, you'd write this:
    [...]
    loader.completedSignaler.bind(fillPage);
}
private function fillPage(feed:Xml):Void {
    [...]
}
With orca, you'd write this:
    [...]
    Binder.bind(loader.completedSignaler, fillPage(signal.data));
}
private function fillPage(feed:Xml):Void {
    [...]
}
You're basically informing the signaler that it should call the fillPage method, with the data of the signal as an argument.

Not so different? Well, here's the revolutionary part: you can also do this:
    [...]
    var page:Page = createPage();
    Binder.bind(loader.completedSignaler, fillPage(page, signal.data));
}
private function fillPage(targetPage:Page, feed:Xml):Void {
    [...]
}

Or this:
    [...]
    Binder.bind(loader.completedSignaler, fillPage("How to start a restaurant in Kuala Lumpur", signal.data));
}
private function fillPage(title:String, feed:Xml):Void {
    [...]
}

Pretty cool huh?

You can try it yourself by making a checkout of http://hxhsl.googlecode.com/svn/branches/orca/. An example of its use has been posted to pastebin.

So, give it a go and let me hear those thoughts!

Current drawbacks:
  • Binder.bind(signaler, listener) seems less readable than signaler.bind(listener). This is because haXe currently wants macros to be static.
  • Things like Binder.bind(signaler, listener(signal.data + 2)) don't work. The binder will be extended at some point to support such functionalities, which will make this new version even more useful.

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Experimental HSL version (needs feedback)

Andy Li
Hi Pimm,

It looks interesting! I've just checked out and looked into it.
The "revolutionary part" is really cool, but I really don't like "Binder.bind" and would like to have a API more close to the current version.

What about:
someSignaler.bind(myListernerFunction, [123, signalData]);

which signalData is actually an Enum, so the whole [123, signalData] is simply an Array<Dynamic>. And the bind is a normal non-macro method and have the magical marco call inside it.

In this case the method may run even without macros, in run-time.

Cheers,
Andy

On Sat, Oct 9, 2010 at 7:29 PM, Pimm Hogeling <[hidden email]> wrote:
Hi list,

I've been looking at macros and how they could improve the HSL experience. An experimental version of HSL, codenamed "orca", has been committed to the branches. I would like to hear from you, the haXe developers, what you think of this version.

Obviously, it's just a proof of concept. It's missing a lot of functionality. This will all be added.

So what changed, you ask. Basically, it's all about the syntax. In the current version of HSL, you'd write this:
    [...]
    ball.bouncedSignaler.bindVoid(playBounceSound);
}
private function playBounceSound():Void {
    [...]
}
With orca, you'd write this:
    [...]
    Binder.bind(ball.bouncedSignaler, playBounceSound);
}
private function playBounceSound():Void {
    [...]
}

In the current version of HSL, you'd write this:
    [...]
    loader.completedSignaler.bind(fillPage);
}
private function fillPage(feed:Xml):Void {
    [...]
}
With orca, you'd write this:
    [...]
    Binder.bind(loader.completedSignaler, fillPage(signal.data));
}
private function fillPage(feed:Xml):Void {
    [...]
}
You're basically informing the signaler that it should call the fillPage method, with the data of the signal as an argument.

Not so different? Well, here's the revolutionary part: you can also do this:
    [...]
    var page:Page = createPage();
    Binder.bind(loader.completedSignaler, fillPage(page, signal.data));
}
private function fillPage(targetPage:Page, feed:Xml):Void {
    [...]
}

Or this:
    [...]
    Binder.bind(loader.completedSignaler, fillPage("How to start a restaurant in Kuala Lumpur", signal.data));
}
private function fillPage(title:String, feed:Xml):Void {
    [...]
}

Pretty cool huh?

You can try it yourself by making a checkout of http://hxhsl.googlecode.com/svn/branches/orca/. An example of its use has been posted to pastebin.

So, give it a go and let me hear those thoughts!

Current drawbacks:
  • Binder.bind(signaler, listener) seems less readable than signaler.bind(listener). This is because haXe currently wants macros to be static.
  • Things like Binder.bind(signaler, listener(signal.data + 2)) don't work. The binder will be extended at some point to support such functionalities, which will make this new version even more useful.

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Experimental HSL version (needs feedback)

Dion Amago
Could you combine "using" with macros?  So then you could do

using Binder;
...

ball.bouncedSignaler.bind(playBounceSound);

even though the compiler is converting it to the original static call.
 That way you could satisfy both camps (those that don't mind the
static call, and those that want the syntax more like the original.

Dion


On Sat, Oct 9, 2010 at 11:55 AM, Andy Li <[hidden email]> wrote:

> Hi Pimm,
> It looks interesting! I've just checked out and looked into it.
> The "revolutionary part" is really cool, but I really don't like
> "Binder.bind" and would like to have a API more close to the current
> version.
> What about:
> someSignaler.bind(myListernerFunction, [123, signalData]);
> which signalData is actually an Enum, so the whole [123, signalData] is
> simply an Array<Dynamic>. And the bind is a normal non-macro method and have
> the magical marco call inside it.
> In this case the method may run even without macros, in run-time.
> Cheers,
> Andy
>
> On Sat, Oct 9, 2010 at 7:29 PM, Pimm Hogeling <[hidden email]>
> wrote:
>>
>> Hi list,
>>
>> I've been looking at macros and how they could improve the HSL experience.
>> An experimental version of HSL, codenamed "orca", has been committed to the
>> branches. I would like to hear from you, the haXe developers, what you think
>> of this version.
>>
>> Obviously, it's just a proof of concept. It's missing a lot of
>> functionality. This will all be added.
>>
>> So what changed, you ask. Basically, it's all about the syntax. In the
>> current version of HSL, you'd write this:
>>     [...]
>>     ball.bouncedSignaler.bindVoid(playBounceSound);
>> }
>> private function playBounceSound():Void {
>>     [...]
>> }
>> With orca, you'd write this:
>>     [...]
>>     Binder.bind(ball.bouncedSignaler, playBounceSound);
>> }
>> private function playBounceSound():Void {
>>     [...]
>> }
>>
>> In the current version of HSL, you'd write this:
>>     [...]
>>     loader.completedSignaler.bind(fillPage);
>> }
>> private function fillPage(feed:Xml):Void {
>>     [...]
>> }
>> With orca, you'd write this:
>>     [...]
>>     Binder.bind(loader.completedSignaler, fillPage(signal.data));
>> }
>> private function fillPage(feed:Xml):Void {
>>     [...]
>> }
>> You're basically informing the signaler that it should call the fillPage
>> method, with the data of the signal as an argument.
>>
>> Not so different? Well, here's the revolutionary part: you can also do
>> this:
>>     [...]
>>     var page:Page = createPage();
>>     Binder.bind(loader.completedSignaler, fillPage(page, signal.data));
>> }
>> private function fillPage(targetPage:Page, feed:Xml):Void {
>>     [...]
>> }
>>
>> Or this:
>>     [...]
>>     Binder.bind(loader.completedSignaler, fillPage("How to start a
>> restaurant in Kuala Lumpur", signal.data));
>> }
>> private function fillPage(title:String, feed:Xml):Void {
>>     [...]
>> }
>>
>> Pretty cool huh?
>>
>> You can try it yourself by making a checkout of
>> http://hxhsl.googlecode.com/svn/branches/orca/. An example of its use has
>> been posted to pastebin.
>>
>> So, give it a go and let me hear those thoughts!
>>
>> Current drawbacks:
>>
>> Binder.bind(signaler, listener) seems less readable than
>> signaler.bind(listener). This is because haXe currently wants macros to be
>> static.
>> Things like Binder.bind(signaler, listener(signal.data + 2)) don't work.
>> The binder will be extended at some point to support such functionalities,
>> which will make this new version even more useful.
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Experimental HSL version (needs feedback)

Andy Li
I've tried a few different ways of combining "using" and macros, but no, it does not compile (at this moment) with anything similar to:
@:macro public static function bind(s:Signaler, expr:Expr):Expr { ... }

Best,
Andy

On Sun, Oct 10, 2010 at 1:39 AM, Dion Amago <[hidden email]> wrote:
Could you combine "using" with macros?  So then you could do

using Binder;
...

ball.bouncedSignaler.bind(playBounceSound);

even though the compiler is converting it to the original static call.
 That way you could satisfy both camps (those that don't mind the
static call, and those that want the syntax more like the original.

Dion


On Sat, Oct 9, 2010 at 11:55 AM, Andy Li <[hidden email]> wrote:
> Hi Pimm,
> It looks interesting! I've just checked out and looked into it.
> The "revolutionary part" is really cool, but I really don't like
> "Binder.bind" and would like to have a API more close to the current
> version.
> What about:
> someSignaler.bind(myListernerFunction, [123, signalData]);
> which signalData is actually an Enum, so the whole [123, signalData] is
> simply an Array<Dynamic>. And the bind is a normal non-macro method and have
> the magical marco call inside it.
> In this case the method may run even without macros, in run-time.
> Cheers,
> Andy
>
> On Sat, Oct 9, 2010 at 7:29 PM, Pimm Hogeling <[hidden email]>
> wrote:
>>
>> Hi list,
>>
>> I've been looking at macros and how they could improve the HSL experience.
>> An experimental version of HSL, codenamed "orca", has been committed to the
>> branches. I would like to hear from you, the haXe developers, what you think
>> of this version.
>>
>> Obviously, it's just a proof of concept. It's missing a lot of
>> functionality. This will all be added.
>>
>> So what changed, you ask. Basically, it's all about the syntax. In the
>> current version of HSL, you'd write this:
>>     [...]
>>     ball.bouncedSignaler.bindVoid(playBounceSound);
>> }
>> private function playBounceSound():Void {
>>     [...]
>> }
>> With orca, you'd write this:
>>     [...]
>>     Binder.bind(ball.bouncedSignaler, playBounceSound);
>> }
>> private function playBounceSound():Void {
>>     [...]
>> }
>>
>> In the current version of HSL, you'd write this:
>>     [...]
>>     loader.completedSignaler.bind(fillPage);
>> }
>> private function fillPage(feed:Xml):Void {
>>     [...]
>> }
>> With orca, you'd write this:
>>     [...]
>>     Binder.bind(loader.completedSignaler, fillPage(signal.data));
>> }
>> private function fillPage(feed:Xml):Void {
>>     [...]
>> }
>> You're basically informing the signaler that it should call the fillPage
>> method, with the data of the signal as an argument.
>>
>> Not so different? Well, here's the revolutionary part: you can also do
>> this:
>>     [...]
>>     var page:Page = createPage();
>>     Binder.bind(loader.completedSignaler, fillPage(page, signal.data));
>> }
>> private function fillPage(targetPage:Page, feed:Xml):Void {
>>     [...]
>> }
>>
>> Or this:
>>     [...]
>>     Binder.bind(loader.completedSignaler, fillPage("How to start a
>> restaurant in Kuala Lumpur", signal.data));
>> }
>> private function fillPage(title:String, feed:Xml):Void {
>>     [...]
>> }
>>
>> Pretty cool huh?
>>
>> You can try it yourself by making a checkout of
>> http://hxhsl.googlecode.com/svn/branches/orca/. An example of its use has
>> been posted to pastebin.
>>
>> So, give it a go and let me hear those thoughts!
>>
>> Current drawbacks:
>>
>> Binder.bind(signaler, listener) seems less readable than
>> signaler.bind(listener). This is because haXe currently wants macros to be
>> static.
>> Things like Binder.bind(signaler, listener(signal.data + 2)) don't work.
>> The binder will be extended at some point to support such functionalities,
>> which will make this new version even more useful.
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Experimental HSL version (needs feedback)

Pimm Hogeling
In reply to this post by Andy Li
On 9 October 2010 18:55, Andy Li <[hidden email]> wrote:
It looks interesting! I've just checked out and looked into it.
The "revolutionary part" is really cool, but I really don't like "Binder.bind" and would like to have a API more close to the current version.
I agree. Revolutionary part is cool, new API isn't as cool. However, as mentioned, haXe currently only does statis macros. I think this might be the best API we can come up with with all this awesome functionality we can get with the current state of haXe.

On 9 October 2010 18:55, Andy Li <[hidden email]> wrote:
What about:
someSignaler.bind(myListernerFunction, [123, signalData]);

which signalData is actually an Enum, so the whole [123, signalData] is simply an Array<Dynamic>. And the bind is a normal non-macro method and have the magical marco call inside it.
Having enums would be an alternative. However, having internal macro calls doesn't sound too useful.

On 9 October 2010 19:39, Dion Amago <[hidden email]> wrote:
Could you combine "using" with macros?  So then you could do

using Binder;
...

ball.bouncedSignaler.bind(playBounceSound);

even though the compiler is converting it to the original static call.
 That way you could satisfy both camps (those that don't mind the
static call, and those that want the syntax more like the original.
As Andy pointed out, this is not possible for as far as I know.

Thanks for the replies so far, guys. Keep it coming.

--
haXe - an open source web programming language
http://haxe.org