Change base class via macro or conditional flag.

57 views
Skip to first unread message

Alexander Kuzmenko

unread,
Jul 20, 2013, 10:06:38 AM7/20/13
to haxe...@googlegroups.com
Hello!

I have some class, which extends another class. I'm looking for a way to change that another class depending on compilation flags.
AFAIK, i can't change parent class with build macro. Perhaps i can do something like this?

#if custom_another
class Some extends #value(custom_another) {
#else
class Some extends Another {
#end


Juraj Kirchheim

unread,
Jul 21, 2013, 2:24:58 PM7/21/13
to haxe...@googlegroups.com
That's impossible. At the same time I would point out that using composition over inheritance would sidestep the issue (and many others) ;)

Alexander Kuzmenko

unread,
Jul 21, 2013, 3:25:45 PM7/21/13
to haxe...@googlegroups.com
Too bad.

I don't think this will lead to any new issues, because we already can do like this:
#if custom_another
class Some extends CustomAnother {
#else
class Some extends Another {
#end
I just need more flexible way :)

Nicolas Cannasse

unread,
Jul 21, 2013, 4:41:16 PM7/21/13
to haxe...@googlegroups.com
Le 20/07/2013 16:06, Alexander Kuzmenko a �crit :
Try with haxe.macro.MacroType<{my.Macro.getType()}>

Best,
Nicolas

Alexander Kuzmenko

unread,
Jul 21, 2013, 5:15:34 PM7/21/13
to haxe...@googlegroups.com
Thanks! 
It works with square brackets instead of curly ones.


On Monday, July 22, 2013 12:41:16 AM UTC+4, Nicolas Cannasse wrote:
Le 20/07/2013 16:06, Alexander Kuzmenko a �crit :
Reply all
Reply to author
Forward
0 new messages