new libs: hxplugins and partials

38 views
Skip to first unread message

Cauê Waneck

unread,
Dec 14, 2011, 9:41:34 AM12/14/11
to haxe...@googlegroups.com
Now sending to the right list :)

Hey guys!

Just a notice, I've made a couple of simple libs to make it easy to work with code extensions, plugins and code separation.

The first one is hxplugins (http://code.google.com/p/hxplugins), which adds the possibility to add type-checked hooks to your code, and the second is partials (http://code.google.com/p/partials/) which adds the possibility of having partial classes (like C#'s http://en.wikibooks.org/wiki/C_Sharp_Programming/Partial_classes). Both have some examples as test cases on the source code, and they are added to haxelib with a experimental character, and suggestions are very welcome! 

Macros are so fun :)
Cheers!

Cauê

Juraj Kirchheim

unread,
Dec 14, 2011, 10:06:01 AM12/14/11
to haxe...@googlegroups.com
Hi Caue,

nice work!

From what I understand Partial classes are somewhat like Ruby mixins?

I had a very similar mechanism in Tinkerbell, because for years I had
been waiting for haXe to have such a feature (extensions are cool, but
don't help you at runtime or implementing interfaces).

Funnily enough shortly after I finally had mixins, I implemented
syntactic delegation and decided to throw mixins away.

Of course I had never thought of using partial classes as a way to
separate platform specific code, but rather as a general mechanism for
code reuse.

As for hxplugins, I will have to look at the examples to get a better
idea of what it does, but it sounds promising ;)

Cauê Waneck

unread,
Dec 14, 2011, 10:30:20 AM12/14/11
to haxe...@googlegroups.com
Hi Juraj!

Hi Caue,

nice work!

Thanks ! :) 

From what I understand Partial classes are somewhat like Ruby mixins?

Well, not entirely, they are definitions of a same class spread across multiple files.  The difference is that you can't use the same code on another class; On C# this is done mostly to ensure MVC in a same class, but my main goal was really to separate target-specific behavior while still avoiding another indirection layer. This was specially important to js for me, because Js people really hate (and well, rightly so) boilerplate code, and there would have to have lots of indirection to separate target-specific code in different places (or just fill all the code with ugly #if platform directives :) )

I had a very similar mechanism in Tinkerbell, because for years I had
been waiting for haXe to have such a feature (extensions are cool, but
don't help you at runtime or implementing interfaces).

Funnily enough shortly after I finally had mixins, I implemented
syntactic delegation and decided to throw mixins away.

hahaha : ) I see why. I'm not usually very comfortable with mixins in general, but there would have to be very small changes in partials code to support them.

As for hxplugins, I will have to look at the examples to get a better
idea of what it does, but it sounds promising ;)

Well, it's a simple way to be able to add hooks to existing code so plugins can override a behavior. It's roughly insipired by Wordpress' plugin hooks. Not the best insipiration, I know, so I'm open to better suggestions :) I just needed a way to make my code open for plugins, without having to change its whole architecture.

Cheers!
Cauê
Reply all
Reply to author
Forward
0 new messages