LINQ in D [Was: Re: Map/Reduce/Filter]
Robert Fraser
fraserofthenight at gmail.com
Thu Jun 19 11:51:59 PDT 2008
bearophile Wrote:
> Walter Bright:
> > We could sure use an article like this for D:
> > http://www.25hoursaday.com/weblog/2008/06/16/FunctionalProgrammingInC30HowMapReduceFilterCanRockYourWorld.aspx
> > Anyone game?
>
> You know that I have spent many months to write a large group of mostly functional-style open source libs for D 1.x (quite more complete and smarter than the stuff in std.algorithm of 2.x, but possibly a bit slower), and on my blog I have discussed many times about this topic, showing usage examples too. So writing another smallish article about such usages seems possible.
> But that article looks mostly about LINQ, that's much better (mostly because it's more integrated and pervasive in the language and systems usable from it, like the DBMS) than anything I can create with D. So maybe a comparison will not show many advantages compared to that LINQ code...
>
> If someone else has some suggestions I'll willing to listen to them.
>
> Bye and thank you for the suggestion,
> bearophile
LINQ should actually be possible in D without language integration.
For example, with CTFE/templates this should be possible in D right now:
struct Employee {
string name;
int id;
}
Employee[] employees;
//...
auto rows = mixin(query("SELECT name, id FROM employees WHERE id > 5"));
foreach(row; rows)
writefln("%d - %s", row.id, row.name);
More information about the Digitalmars-d
mailing list