Hi all,
Although Groovy and Java 8+ can handle data structure easily, it is
still less easier and readable than LINQ IMHO.
I tried to implement it at the language level and found too many
keywords will be introduced to Groovy, so I think LINQ-like DSL will be more
feasible. e.g.
def nums = [0, 1, 2, 3]
// command chain expression can not span rows, so we can use closure
to wrap expressions
def numQuery = linq { // numQuery is an Iterator<Integer>
from num of nums // in is a keyword of groovy, so use of
instead. Maybe some other word is better?
where num % 2 == 0
select num
}
for (num in numQuery) { /* do with the result */ }
Note: linq, from, of, where, select are all methods and others are their
parameters. Beside the basic use case, joining, grouping etc. are all in the
TODO list :)
The DSL will be a big work, it will last long. Before I find some
time to working on it, I wish you like the LINQ-like DSL idea, although it
is not mature enough for the time being ;)
Cheers,
Daniel.Sun
--
View this message in context:
http://groovy.329449.n5.nabble.com/About-LINQ-like-DSL-for-Groovy-tp5742132.html
Sent from the Groovy Dev mailing list archive at Nabble.com.