[nem-en] detecting class methods from a macro?
Valient Gough
valient at gmail.com
Tue Jan 31 06:45:35 CET 2006
Hi,
I've been playing with nemerle for a while, and more recently with
macros. But macros are still something of a black art to me in some
ways. For example, is there a way to make use of reflection
information in a macro?
For example, I want my macro to generate code based on the methods
available in a class, ie:
public class Foo
{
public void func1();
}
public class Bar
{
public void func2();
}
macro callAppropriate( arg )
{
// if arg.func1() exists, then generate a call to it
// if arg.func2() exists, then generate a call
}
....
callAppropriate( foo );
callAppropriate( bar );
My real code is more complicated of course (there are a set of
possible functions, and a class can implement more then one, so I have
to generate a call for all available methods). Sure I could generate
some sort of reflection lookup at runtime, but if it is possible I'd
rather have the macro generate just the necessary calls.
Is this possible? Is there some example macro code that I should be looking at?
thanks,
Valient
More information about the devel-en
mailing list