const string type parameter reification

56 views
Skip to first unread message

Stephane Le Dorze

unread,
Nov 14, 2015, 3:31:11 PM11/14/15
to Haxe
anyone knows how to reify a const string as a type parameter (using a variable) during a macro class creation? (not sure it's possible syntactically).


I would like to do something like:

macro class Bar {
..
function myMeth() : Foo<$cstringName>
...
}

Instead of building it by myself like :

var myType = TPath({
      name : "Foo",
      pack : [],
      params : [
        TPExpr({
          expr : EConst(CString(cstringName)), pos : cpos
        }),
      ]
    });

macro class Bar {
..
function myMeth() : $myType 
...
}


Morph being of the form:

class Foo<Const> {
...
}

Thanks in advance,
Stephane

Juraj Kirchheim

unread,
Nov 15, 2015, 8:52:08 AM11/15/15
to haxe...@googlegroups.com
With strings it does work like so:

  macro class Bar {
    function myMeth() : Foo<'$cstringName'>;
  }

With other types of constants, I think you will have to do it by hand.

Best,
Juraj

--
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.

Stephane Le Dorze

unread,
Nov 15, 2015, 10:56:18 AM11/15/15
to haxe...@googlegroups.com
Oh thank you Juraj!
Too bad for the other forms... have this already been discussed to death or should I open an Issue?

Best,
Stephane


You received this message because you are subscribed to a topic in the Google Groups "Haxe" group.

For more options, visit https://groups.google.com/d/optout.

Juraj Kirchheim

unread,
Nov 15, 2015, 3:37:44 PM11/15/15
to haxe...@googlegroups.com
Not to my knowledge. I guess sophisticated type reification is just not that common ;)

Best,
Juraj

Philippe Elsass

unread,
Nov 16, 2015, 4:49:00 PM11/16/15
to Haxe
Oooh, does it work for class names?
eg. macro class '$cstringName' { }
Philippe

Stephane Le Dorze

unread,
Nov 16, 2015, 4:50:13 PM11/16/15
to haxe...@googlegroups.com
var newClass = macro class $clazzName {
    ....
Reply all
Reply to author
Forward
0 new messages