No household is perfect

Simen Kjærås simen.kjaras at gmail.com
Thu Dec 5 01:11:07 PST 2013


On 2013-12-05 05:09, Shammah Chancellor wrote:
> On 2013-12-04 03:23:59 +0000, bearophile said:
>
> Joshua Niehus:
>
> This would make for a good blog post/wiki article.Does one already exist?
>
> If you have a AST macros like in Julia language, I think you can write
> something like:
>
> @setExpr(a ∪ (b ∩ c));
>
> The main difference is that the compiler gives you a tree in the macro
> to work on, instead of a string to parse and munge.
>
> Bye,
>
> bearophile
>
> Can't you define
>
> template setExpr(string expr)
> {
>     PeggedStuff...
>
>     mixin(PeggedStuff());
> }
>
>
> setExpr!(q{a ∪ (b ∩ c)});?


It'd have to be:

     template setExpr(string expr)
     {
         PeggedStuff...
         enum setExpr = PeggedStuff();
     }

     mixin(setExpr!q{a ∪ (b ∩ c)});

for it to have access to the names a, b and c.

Apart from that, absolutely.


One of the problems would be the lack of type information. If it turns 
out that a is string, not a Set!int,

--
   Simen


More information about the Digitalmars-d mailing list