Operator overloading or alternatives to expression templates

Sebastiaan Koppe via Digitalmars-d digitalmars-d at puremagic.com
Mon Sep 14 18:25:00 PDT 2015


On Monday, 14 September 2015 at 18:17:05 UTC, Adam D. Ruppe wrote:
> On Monday, 14 September 2015 at 13:47:10 UTC, Sebastiaan Koppe 
> wrote:
>> `auto q = query.builder!Person.age!">"(20).name("Peter");`
>
> I confess that I'm not really paying attention to this thread, 
> but I can't help but think plain old literal: `Person.age > 20 
> && Person.name = 'Peter'` is nicer. You can still CT check that 
> by parsing the string if you want.

It is definitely nicer, but this is also a contrived use-case. 
What happens when you have a couple of joins, how would you write 
that? Or inner queries?

Suppose we wanted to fetch all users who didn't place an order in 
the last year, it would be as simple as calling 
`.lastOrderDate!"<"(lastYear)`. It would do the join with the 
order table on the appropriate column.

Granted, someone has to write `lastOrderDate()`.


More information about the Digitalmars-d mailing list