On Monday, 11 November 2013 at 09:02:01 UTC, bearophile wrote:
Jacob Carlborg:
One of my favorite examples is the database query:
auto person = Person.where(e => e.name == "John");
Which translates to the following SQL:
select * from person where name = 'John'
Can't you do the same thing with functions similar (same API
but different semantics) to std.algorithm ones that generate
expression templates?
auto person = persons.filter!(e => e.name == "John");
The problem here is that a library need to know that it has to
create
SELECT * FROM persons WHERE name = 'John';
and not
SELECT * FROM persons;
and filter it locally.
So it needs a way to inspect the body of the delegate and extract
"name" "==" and "John".
--------
simendsjo:
* Number intervals, like "int i = int[10..20];" where only 10
to 20 are legal values
What's wrong with this syntax that doesn't reqiire macros? It's
more uniform with the rest of the language:
Ranged!(int, 10, 20) i;
Bye,
bearophile
Nothing wrong with it, I was just trying to come up with some
examples. I don't say they're necessarily good :)