Operator overloading or alternatives to expression templates
Jacob Carlborg via Digitalmars-d
digitalmars-d at puremagic.com
Sat Sep 12 07:15:09 PDT 2015
On 2015-09-11 21:40, Martin Nowak wrote:
> I find the reasons for turining down my ER a bit moot.
>
> [Issue 14593 – operator overloading can't be used with expression
> templates](https://issues.dlang.org/show_bug.cgi?id=14593)
>
> AFAIK expression templates are the primary choice tom implement SIMD and
> matrix libraries.
> And I still have [this idea](http://dpaste.dzfl.pl/cd375ac594cf) of
> implementing a nice query language for ORMs.
I would really like this.
> The short circuit operators && and || have a special semantic and can't
> be easily, but there is & and | so it's not really required.
Not sure if this would be a problem in D but there's a library in Ruby
that does exactly this. Due to the operator precedence you end up
needing to wrap everything in parentheses:
Person.where{ |p| (p.age > 21) & (p.name == "Peter") | (p.name == "Foo") }
> Does anyone have a different idea how to make a nice query language?
> db.get!Person.where!(p => p.age > 21 && p.name == "Peter")
AST macros ;)
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list