Extended Type Design.

eao197 eao197 at intervale.ru
Sat Mar 17 14:05:38 PDT 2007


On Sat, 17 Mar 2007 11:49:59 +0300, Walter Bright  
<newshound at digitalmars.com> wrote:

> It's pretty simple:
>
> 	macro foo(args)
> 	{
> 		...syntax that gets inserted...
> 	}
>
> and the args and syntax is evaluated in the context of the invocation of  
> the macro, not the definition of the macro. You'll be able to do things  
> like:
>
> 	macro print(arg)
> 	{
> 		writefln(__FILE__, __LINE__, arg);
> 	}
>
> which get the file and line in the right context. There's no way to do  
> that right now.

As I can see the content of macro body will be inserted into AST in the  
place of invocation. But there is not much differences with existing  
C/C++ macro handling (insertion of right __FILE__, __LINE__ is good thing  
anyway).

Is there allowed any access to previous parsed entity? For example, can I  
define macro:

macro some_class_extender(class_name) {
   ...modification of 'class_name' class structure...
}

class MyCoolClass { ... }
some_class_extender( MyCoolClass );

and get the modified version of MyCoolClass after some_class_externder  
invocation?

-- 
Regards,
Yauheni Akhotnikau



More information about the Digitalmars-d mailing list