Is this lambda? if not what is it?
Asked Answered
D

1

8

a few days back i was trying the new ORM for delphi from Devart called EntityDAC, well i was reading the docs specific the LINQ part, when i saw something like:

Linq.From(Emp).Where(Emp['Sal'] > 1000)

got to say that wake me up the first moment i saw. the expression "Emp['Sal'] > 1000" isn't a lambda expression?! since the trial version is this component don't come with sources i couldn't figure out how Where function/procedure is declared.

reference: http://www.devart.com/entitydac/docs/ -> Linq Queries -> Linq Syntax -> Scroll down to Where session

Durga answered 13/1, 2015 at 20:41 Comment(7)
I don't think that can be Pascal because the Emp['Sal'] > 1000 expression will be evaluated before calling Where. Why don't you ask Devart?Spencer
EntityDAC is available for .net and delphi and for sure especially the linq part is different. But there is also a chapter Specifying LINQ Query Arguments as String and I guess you have to use that with delphiFerrotype
@DavidHeffernan What about operator overloading? Couldn't you accomplish something like by building up a list of values in the operator overload code and then using that list in the where? You effectively return an unused result.Sambar
@Sambar Yes I suppose so. As Mason outlines.Spencer
As soon as some people have some kind of query and an expression they starting to call that LINQ (maybe marketing?). LINQ is a .NET technology and even though it might not be copyrighted there are no other languages (except other .NET targeting languages) that have LINQ. They might have some similar or different API for streaming enumerables but it's still something different.Eagan
@StefanGlienke: I suppose you would know... ;)Alixaliza
@Mason Good catch. Guess why I never finished it. I was trying to do something like linq-to-sql with creating classes from a DB schema but it turned out that it just did not work the way I wanted. these two units are the sad remains of that project. :)Eagan
A
13

I mentioned this in a blog post a few months ago. I don't have the source to look at, but it's almost certainly done this way:

  • The expression Emp['Sal'] returns a value of a record type
  • This record has operator overloads declared on it
  • The Delphi language defines operator overloads as functions, and does not require them to return any specified or intuitive type. Therefore, the > operator here does not return a boolean, but rather another record.
  • By chaining these operators, an expression tree can be created, which can be evaluated by their LINQ evaluator.
Alixaliza answered 13/1, 2015 at 21:26 Comment(1)
thx for your attention, i didn't know that delphi had this feature. i'ill surely look furtherDurga

© 2022 - 2024 — McMap. All rights reserved.