Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is this lambda? if not what is it?

Tags:

orm

delphi

devart

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

like image 776
kabstergo Avatar asked Jan 13 '15 20:01

kabstergo


1 Answers

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.
like image 159
Mason Wheeler Avatar answered Oct 05 '22 01:10

Mason Wheeler