This page is no longer maintained — Please continue to the home page at www.scala-lang.org

about the LiftCode compilation phase

3 replies
Miguel Garcia
Joined: 2009-06-10,
User offline. Last seen 42 years 45 weeks ago.

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.

Miguel
http://www.sts.tu-harburg.de/people/mi.garcia

extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.
Re: about the LiftCode compilation 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.

Johannes Rudolph
Joined: 2008-12-17,
User offline. Last seen 29 weeks 20 hours ago.
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...

Miguel Garcia
Joined: 2009-06-10,
User offline. Last seen 42 years 45 weeks ago.
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.

Miguel
http://www.sts.tu-harburg.de/people/mi.garcia

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland