feature request: __ARGS__ for logging (cf __FILE__, __LINE__, __FUNC___)
Timon Gehr
timon.gehr at gmx.ch
Tue Feb 5 03:05:04 PST 2013
On 02/05/2013 08:28 AM, Jacob Carlborg wrote:
> On 2013-02-05 01:15, Timon Gehr wrote:
>
>> IMO macros should be fully hygienic by default, with opt-out options.
>
> That's the opposite of how the macros in Scala works.
>
As far as my understanding goes, quasi-quoting is hygienic, and manual
AST building provides both options.
> It's quite easy to say if it should be hygienic or not. The hard part is
> to figure out the details and how to break hygienicy, when there's need
> for it.
>
We could provide all nested scopes in an array as part of the context.
macro foo(Context context){
return<[
context.scopes[0].x++;
context.scopes[1].x++;
]>;
}
int x = 2;
void main(){
int x=0;
foo();
assert(x==1 && .x==3);
}
If manual AST building is supported, it could additionally do something
along the following lines:
module macros;
int x=0;
macro foo(Context context){
return SequenceExp(
AssignExp(Symbol!x(), Constant(1)),
AssignExp(Identifier("x"), Constant(2)),
);
}
// ---
module m;
import macros;
int x=0;
void main(){
foo();
assert(macros.x==1 && x==2);
}
More information about the Digitalmars-d
mailing list