Macro for a generic method

35 views
Skip to first unread message

Kevin ResoL

unread,
May 15, 2014, 11:54:30 AM5/15/14
to haxe...@googlegroups.com
Hey, I've got a question about Haxe macro. I know that I can build a class with macro. Say I want to have a `clone()`function which simply copy all properties of a instance to a new one, I can do this at runtime using `Reflect`. I can also do it at compile time using macro, i.e. loop through all member properties and create an assignment expression for each of them.

Kevin Leung[11:09 AM]
Now my question is:
If I want to create a utility function that clone any objects.
```@:generic
public static function clone<T>(object:T):T
```

Kevin Leung[11:10 AM]Is it possible to use macro to generate the assignment expressions instead of using Reflect at runtime?
Reply all
Reply to author
Forward
0 new messages