Operator overloading or alternatives to expression templates
Bahman Movaqar via Digitalmars-d
digitalmars-d at puremagic.com
Sat Sep 12 15:38:39 PDT 2015
On Fri, 11 Sep 2015 21:40:58 +0200, Martin Nowak
<code+news.digitalmars at dawg.eu> wrote:
> Does anyone have a different idea how to make a nice query language?
> db.get!Person.where!(p => p.age > 21 && p.name == "Peter")
Django's approach is, IMO, the cleverest and least magical one while
keeping it expressive and efficient:
Person.objects.filter(age__gt=21, name__eq='peter')
The input of `filter` is keyword argument style. So, filter can
access the dynamic argument names, in addition to their values. This
makes it easy to understand user's intent without the need to
overloaded operators or black magic (like repeated reflections
Hibernate uses) and the syntax stays clean from user's perspective as
well.
--
--
Bahman Movaqar
More information about the Digitalmars-d
mailing list