Scala equivalent to C#'s Expression API
reflection, scala
Solution
This is not supported by Scala. ScalaQL: Language-Integrated Database Queries for Scala describes a LINQ-like functionality in Scala:
While it is possible for Microsoft to simply extend their language with this particular feature, lowly application developers are not so fortunate. For exam- ple, there is no way for anyone (outside of Sun Microsystems) to implement any form of LINQ within Java because of the language modications which would be required. We faced a similar problem attempting to implement LINQ in Scala.
Fortunately, Scala is actually powerful enough in and of itself to implement a form of LINQ even without adding support for expression trees. Through a combination of operator overloading, implicit conversions, and controlled call- by-name semantics, we have been able to achieve the same eect without making any changes to the language itself.
Problem
Is their an equivalent to C#'s Expression API in scala? For example, I would like to have a lambda like this: ``` (Foo) => Foo.bar ``` and be able to access "bar" in the function it is passed to.