DIP 50 - AST macros

Jacob Carlborg doob at me.com
Wed Nov 20 00:04:27 PST 2013


On 2013-11-19 21:54, luka8088 wrote:

> Well, do think about that :)
>
> auto f = e => e.name == "John";
> if (true)
>    f = e => e.name == "Jack";
>
> auto person = Person.where(f);
>
> I can think of a many use cases where conditional query generation is
> required. But I don't see how this could be done using AST macros.

Using the Rails plugin, which I've got this idea from, I would not make 
the lambda conditional but the whole statement, translated to D:

auto person = Person.scoped();

if (true)
     person = person.where(e => e.name == "Jack");

else
     person = person.where(e => e.name == "John");

> Um, sorry. I don't understand the question.
>
> This example (and suggestion) was suppose to show that we could allow
> AST mixins as well as string mixins. It should behave like string mixins
> but the main difference is that AST is structured so it much cleaner to
> manipulate.

What I was trying to say is, what don't you like about my suggestion. Is 
it that the "mixin" keyword isn't used.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list