Additional Binary Operators
Era Scarecrow
rtcvb32 at yahoo.com
Tue Mar 5 13:27:56 PST 2013
On Tuesday, 5 March 2013 at 12:40:32 UTC, Artur Skawina wrote:
> One problem with string-based DSLs is scoping - they only work
> properly when mixed in into the current scope.
>
> auto c = mixin(myDSL!"a?:+:b");
> mixin myDSL!("c", "a?:+:b");
> mixin (myDSL!("c", "a?:+:b"));
> // etc
>
> is sometimes enough, but often the code would be clearer w/o
> the mixin.
Perhaps the mixin (@mixin?) could be moved to a function's
signature as an attribute? Then the compiler knows it's going to
be mixed in and removes the need to do it yourself; Mind you it
would have to return a string to be valid; Or it would be part of
the base signature instead.
string myDSL(string) @mixin;
mixin string myDSL(string);
//now without the mixin..
auto c = myDSL!("a?:+:b");
This seems like it would be an easy thing to add and shouldn't
complicate the language any.
More information about the Digitalmars-d
mailing list