Page 1 of 1

LINQ

PostPosted: Mon Feb 11, 2008 3:14 am
by Charles
I was asked in an email:
What are your plans for LINQ (Expression, Lambda, ...) support in cobra?

The plan is to fully embrace it. Right now Cobra has LINQ Jr:
names = for name in names where name.trim.length get name.trim

So you can enumerate, filter and transform. Obviously there's a lot missing and it's not backed by expression trees so it's not the "real thing". But it was a good start for .NET 2.0.

Re: LINQ

PostPosted: Mon Feb 11, 2008 6:44 pm
by neuruss
So I assume that you are not looking to implement list comprehensions (ala python), since Linq offers the same capabilities.
Is that right?

Re: LINQ

PostPosted: Mon Feb 11, 2008 11:29 pm
by Charles
What Cobra currently offers matches Python's list comprehensions in capability. The syntax is different for two reasons.

One is to match the order that you would use with the statements approach:
results = []
for name in names
if name.trim.length
results.add(name)
names = results
# expression version is same order; reuses brain space:
names = for name in names where name.trim.length get name.trim


The other is to support Intellisense:
names = for name in names where name.trim.length get name._


In Python, they put the transformation expression first:
Code: Select all
names = name._

No Intellisense for you!