[nem-en] expresion level macro to define methods

Kamil Skalski kamil.skalski at gmail.com
Sat Nov 18 00:31:44 CET 2006


I noticed this in your commit. It is quite possible that attributes
attached to property accessors are ignored as this is a special case
in parse trees.

On 11/18/06, Igor Tkachev <it at rsdn.ru> wrote:
> Hello Kamil,
>
> I confirm there is problem with attributes in quotation.
> Yesterday I added DebuggerStepThrough attribute in the Accessor macro
> (it's still there). It's simply ignored.
>
>
>
> Friday, November 17, 2006, 2:16:06 PM, you wrote:
>
> > Kamil Skalski wrote:
> >> Which version of compiler are you using? If it is with svn, then you
> >> should file a bug report.
>
> > I used 0.9.3.
>
> > I just checked that it works properly with the compiler built from the
> > latest source.
>
> >> As a workaround you shoud be able to use:
> >>
> >> def mem_builder =
> >> Nemerle.Macros.ImplicitCTX().CurrentType.DefineAndReturn(a_test);
> >> mem_builder.GetModifiers().AddCustomAttribute (<[ Test ]>);
>
> > That didn't help; still no attribute on the method. But, as I wrote
> > above, it is all fine with the compiler from the latest revision.
>
> > Kamil Dworakowski
> >>
> >> 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
> >>>
> >>
> >>
>
>
> > _______________________________________________
> > https://nemerle.org/mailman/listinfo/devel-en
>
>
>
>
> --
> Best regards,
>  Igor                            mailto:it at rsdn.ru
>
>
>
> _______________________________________________
> https://nemerle.org/mailman/listinfo/devel-en
>


-- 
Kamil Skalski
http://nazgul.omega.pl



More information about the devel-en mailing list