Miguel Garcia | 8 Dec 16:58 2009
Picon

about the LiftCode compilation phase


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/t0651.scala

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

Paul Phillips | 8 Dec 17:31 2009

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.

--

-- 
Paul Phillips      | A Sunday school is a prison in which children do
Stickler           | penance for the evil conscience of their parents. 
Empiricist         |     -- H. L. Mencken
i'll ship a pulp   |----------* http://www.improving.org/paulp/ *----------

Johannes Rudolph | 9 Dec 08:11 2009

Re: about the LiftCode compilation phase

On Tue, Dec 8, 2009 at 5:31 PM, Paul Phillips <paulp@...> 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/net/virtualvoid/bytecode/Tools.scala

--

-- 
Johannes

-----------------------------------------------
Johannes Rudolph
http://virtual-void.net
(Continue reading)

Miguel Garcia | 9 Dec 12:53 2009
Picon

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

----- Original Message ----- 
From: "Johannes Rudolph" <johannes.rudolph@...>
To: "Paul Phillips" <paulp@...>
Cc: "Miguel Garcia" <miguel.garcia@...>; 
<scala-internals@...>
Sent: Wednesday, December 09, 2009 8:11 AM
Subject: Re: [scala-internals] about the LiftCode compilation phase

On Tue, Dec 8, 2009 at 5:31 PM, Paul Phillips <paulp@...> 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
(Continue reading)


Gmane