Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
July 27, 2005 macro help | ||||
---|---|---|---|---|
| ||||
hey im curious, are there any facilities in d for expanding macros beyond a mixin? for example what if i want to pass the source location into a function, for example: in c/c++ i could write a method: _someMethod( int line, string source ); then macro: #define someMethod() _someMethod( _LINE_, _FILE_ ); etc.. how would you do something like this in D ? |
July 27, 2005 Re: macro help | ||||
---|---|---|---|---|
| ||||
Posted in reply to J Thomas | "J Thomas" <jtd514@ameritech.net> wrote in message news:dc7clf$26s3$1@digitaldaemon.com... > hey im curious, are there any facilities in d for expanding macros beyond a mixin? for example what if i want to pass the source location into a function, for example: > > in c/c++ i could write a method: > > _someMethod( int line, string source ); > > then macro: > > #define someMethod() _someMethod( _LINE_, _FILE_ ); > > etc.. > > > how would you do something like this in D ? You'd have to expand the macro by hand. In D __LINE__ and __FILE__ are substituted at the lexer level - so the rest of the parser never knows they exist. |
July 27, 2005 Re: macro help | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | yah thats what i was thinking, bummer...
i love D but im still not completely sold on the no preprocessor
Ben Hinkle wrote:
> "J Thomas" <jtd514@ameritech.net> wrote in message news:dc7clf$26s3$1@digitaldaemon.com...
>
>>hey im curious, are there any facilities in d for expanding macros beyond a mixin? for example what if i want to pass the source location into a function, for example:
>>
>>in c/c++ i could write a method:
>>
>>_someMethod( int line, string source );
>>
>>then macro:
>>
>>#define someMethod() _someMethod( _LINE_, _FILE_ );
>>
>>etc..
>>
>>
>>how would you do something like this in D ?
>
>
> You'd have to expand the macro by hand. In D __LINE__ and __FILE__ are substituted at the lexer level - so the rest of the parser never knows they exist.
>
>
|
July 27, 2005 Re: macro help | ||||
---|---|---|---|---|
| ||||
Posted in reply to J Thomas | You can always run it through a C++ pre-proccessor before compilation. Charlie "J Thomas" <jtd514@ameritech.net> wrote in message news:dc8hvi$d5c$1@digitaldaemon.com... > yah thats what i was thinking, bummer... > > i love D but im still not completely sold on the no preprocessor > > > Ben Hinkle wrote: > > "J Thomas" <jtd514@ameritech.net> wrote in message news:dc7clf$26s3$1@digitaldaemon.com... > > > >>hey im curious, are there any facilities in d for expanding macros beyond > >>a mixin? for example what if i want to pass the source location into a function, for example: > >> > >>in c/c++ i could write a method: > >> > >>_someMethod( int line, string source ); > >> > >>then macro: > >> > >>#define someMethod() _someMethod( _LINE_, _FILE_ ); > >> > >>etc.. > >> > >> > >>how would you do something like this in D ? > > > > > > You'd have to expand the macro by hand. In D __LINE__ and __FILE__ are substituted at the lexer level - so the rest of the parser never knows they > > exist. > > > > |
July 28, 2005 Re: macro help | ||||
---|---|---|---|---|
| ||||
Posted in reply to Charles | "Charles" <noone@nowhere.com> wrote:
> You can always run it through a C++ pre-proccessor before compilation.
[...]
That is definitely not true, because pre-processor directives might be included in D-strings spanning several lines.
-manfred
|
Copyright © 1999-2021 by the D Language Foundation