[nem-en] expresion level macro to define methods
Kamil Skalski
kamil.skalski at gmail.com
Fri Nov 17 19:49:36 CET 2006
Which version of compiler are you using? If it is with svn, then you
should file a bug report.
As a workaround you shoud be able to use:
def mem_builder =
Nemerle.Macros.ImplicitCTX().CurrentType.DefineAndReturn(a_test);
mem_builder.GetModifiers().AddCustomAttribute (<[ Test ]>);
On 11/17/06, Kamil Dworakowski <kamil.dworakowski at googlemail.com> wrote:
> It works fine except that it ignores attributes I define for my method.
> I want the method to have [Test] attribute, but it gets lost somehow. Why?
>
> def a_test = <[
> decl: [Test] public testSth(): void {
> Assert.IsTrue(false);
> }
> ]>;
> Nemerle.Macros.ImplicitCTX().CurrentType.Define(a_test);
>
> Kamil Dworakowski
>
>
> Kamil Skalski wrote:
> > Yes,
> >
> > macro MarkWithMy (expr) {
> > Nemerle.Macros.ImplicitCTX().CurrentType.Define ( <[ decl:
> > public MyGeneratedMethod (x : int) : int {
> > x + $expr
> > }
> > ]>);
> > <[ () ]>
> > }
> >
> > but probably if you tried using this method in compilation of current
> > class/method (for other classes it might be even more indeterministic
> > ;) ), like
> >
> > macro MarkWithMy (expr) {
> > Nemerle.Macros.ImplicitCTX().CurrentType.Define ( <[ decl:
> > public MyGeneratedMethod (x : int) : int {
> > x + $expr
> > }
> > ]>);
> > <[ MyGeneratedMethod(1) ]>
> > }
> >
> > you might get strange problems...
> >
> > On 11/17/06, Kamil Dworakowski <kamil.dworakowski at googlemail.com> wrote:
> >> Is it possible for an expresion lvl macro to define a method on the
> >> enclosing class?
> >>
> >> Kamil Dworakowski
> >>
> >> _______________________________________________
> >> https://nemerle.org/mailman/listinfo/devel-en
> >>
> >
> >
>
>
> _______________________________________________
> https://nemerle.org/mailman/listinfo/devel-en
>
--
Kamil Skalski
http://nazgul.omega.pl
More information about the devel-en
mailing list