[nem-en] macro to define a new kind of member

Kamil Dworakowski kamil.dworakowski at googlemail.com
Sat Feb 24 14:54:08 CET 2007


Kamil Skalski wrote:
> I mean that the idea of having:
>
> macro myWithinClassMacro (tb : TypeBuilder,  extraMods : Modifiers) {
> }
>
> is not very interesting, since the parameter is very specific and
> valid only in our discussed case.
> So I think it should just do:
>
> macro myWithinClassMacro (tb : TypeBuilder,  tokens : TokenGroup) {
>  def (mods, rest) = analyzeAndExtractModifiers (tokens);
> }
>
> (the current implementation after your changes allows exactly this)
>
I have done it so that any modifiers and custom attributes are packed 
into loose groups and appended at the end of the params for the macro call.

Oddly enough it doesn't work if the parameters in the syntax definition 
and the macro signature are in different order. Then I get an 
IndexOutBoundOfArray exception thrown from some method that processes 
parameters in a macro.

I cut the modifiers out of the token stream (set the Next field of the 
last to null). Do you think it is safe or should I copy them? How to 
clone a token?

Kamil Dworakowski



More information about the devel-en mailing list