- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
about the LiftCode compilation phase
Tue, 2009-12-08, 17:08
Hi,
Today I started another code walkthrough, in the naive thinking that the
LiftCode phase had something to do with LambdaLift. To make a long story
short: is there any Scala code *at all* that, when compiled, makes use of
that phase, besides t0651.scala ?
http://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/test/files/pos/t06...
For those craving for context: looks like LiftCode aims at simplifying
"writing code that writes code". Test t0651 reads:
object Reflection1 extends Application {
case class Element(name: String)
println(reflect.Code.lift({val e = Element("someName"); e}).tree)
}
So I guess the net effect of compiling that will be for an AST to be built
as if "Element("someName")" had been parsed? Right? Naive? Comments are
welcome.
Wed, 2009-12-09, 08:17
#2
Re: about the LiftCode compilation phase
On Tue, Dec 8, 2009 at 5:31 PM, Paul Phillips wrote:
> On Tue, Dec 08, 2009 at 04:58:21PM +0100, Miguel Garcia wrote:
>> Today I started another code walkthrough, in the naive thinking that
>> the LiftCode phase had something to do with LambdaLift. To make a long
>> story short: is there any Scala code *at all* that, when compiled,
>> makes use of that phase, besides t0651.scala ?
>
> No. I thought the liftcode object in global was commented out, but I
> see not. It's not the only seeming-phase which is unused. It is
> presumably waiting for someone to finish it.
Still in stealth-mode, but I'm using it since quite a while
successfully even in it's current form to extract
java.lang.reflect.Method objects from calls like
Tools.methodFromObject((str1:String, str2: String) => str1.concat(str2))
In the best case, you can even infer the types from the context, so
you can refer to java.reflect.Method objects in quite a succinct way:
method(_.concat(_)) or method(_.toString) or static calls
'method(Integer.parseInt(_))' or fields 'field(Test.x)'.
see
http://github.com/jrudolph/bytecode/blob/pepm/bytecode/src/main/scala/ne...
Wed, 2009-12-09, 12:57
#3
Re: about the LiftCode compilation phase
Johannes,
That way to use scala.reflect seems cool, however I don't see how your
project might lessen the learning curve for those not familiar with
scala.reflect :-)
It would be great if you could point us to (simpler?) Scala programs relying
on the tandem scala.reflect + LiftCode phase.
On Tue, Dec 08, 2009 at 04:58:21PM +0100, Miguel Garcia wrote:
> Today I started another code walkthrough, in the naive thinking that
> the LiftCode phase had something to do with LambdaLift. To make a long
> story short: is there any Scala code *at all* that, when compiled,
> makes use of that phase, besides t0651.scala ?
No. I thought the liftcode object in global was commented out, but I
see not. It's not the only seeming-phase which is unused. It is
presumably waiting for someone to finish it.