C++0x now with lambda and closure

Robert Fraser fraserofthenight at gmail.com
Tue Apr 1 07:16:45 PDT 2008


downs wrote:
> Jacob Carlborg wrote:
>> guslay wrote:
>>> For those keeping track...
>>>
>>> http://herbsutter.spaces.live.com/
>>>
>>> Crazy syntax, at least it looks better than boost.
>>>
>> I like the C# syntax:
>> listOfFoo.Where(x => x.size > 10);
>>
>> even better if you could have this syntax (but perhaps it won't work):
>> listOfFoo.Where((x) x.size > 10);
>>
>> I would be nice to have that in D
> 
> Well, _kinda_ with tools :)
> 
> listOfFoo /select/ ex!("x -> x.size > 10");
> 
> :)
> 
>  --downs

One of my D library ideas that fell by the wayside was to make a 
compile-time SQL parser. So you could do something like:

string[] results = Query!("
         SELECT groups.name
             FROM groups
             INNER JOIN employees ON employees.groupId = groups.id,
             GROUP BY employees.groupId
             HAVING avg(employees.salary) > 50000
             WHERE group.name != "Accounting" -- Nobody likes them
             ORDER BY group.name
     ");

(or something like that; my SQL's a bit rusty). Ideally, you could have 
an arbitrarily complex query including subqueries. Query would be a 
template of some sort... not sure exactly how this would work... but 
that's my pipe dream, anyway.


More information about the Digitalmars-d-announce mailing list