@:from static macro function (abstracts)

48 views
Skip to first unread message

Laurence Taylor

unread,
Jul 27, 2016, 5:20:04 AM7/27/16
to Haxe

I can’t find enough info…

 @:forward abstract TestMacroFrom(String){
  @:from static public macro function fromStringExpr(str:haxe.macro.Expr):haxe.macro.Expr{
    return macro "Nothing";
  }
}

I would think that might work, but doesn’t. In any case, I’m not sure how to get the function to trigger in the first place.

Any one know what the limitations are?

regards,
Laurence

Andreas Mokros

unread,
Jul 27, 2016, 7:56:32 AM7/27/16
to haxe...@googlegroups.com
Hi.

On Wed, 27 Jul 2016 02:20:03 -0700 (PDT)
Laurence Taylor <polyse...@gmail.com> wrote:
> I would think that might work, but doesn’t. In any case, I’m not sure how
> to get the function to trigger in the first place.

Not sure, I used it and it works for me in some other (more complex) context,
but in your case:
@:forward abstract TestMacroFrom(String) from Dynamic {
...
seems to work.

--
Mockey

Laurence Taylor

unread,
Jul 27, 2016, 8:30:30 AM7/27/16
to haxe...@googlegroups.com
Thanks, I think I see how that might work.

regards,
Laurence



--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.

Andreas Mokros

unread,
Jul 27, 2016, 10:15:35 AM7/27/16
to haxe...@googlegroups.com
Hi.

On Wed, 27 Jul 2016 14:30:27 +0200
Laurence Taylor <polyse...@gmail.com> wrote:
> Thanks, I think I see how that might work.

As I wrote, I'm not sure if it's supposed to be used like this. I used it some
other context (an abstract with parameter <T>) where I didn't need `from
Dynamic`.
Some documentation would be helpful...

--
Mockey

Laurence Taylor

unread,
Jul 27, 2016, 2:05:35 PM7/27/16
to haxe...@googlegroups.com

It's early days, I think. post some issues, see what turns up.

It looks like when you pass an abstract, you get the expression for 'this' that would be passed to the abstract constructor.

my 2¢

Reply all
Reply to author
Forward
0 new messages