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

a code walkthrough of the CleanUp phase of scalac

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

Hi,

I've been meaning for a while to get a clearer picture of the CleanUp phase
of scalac, and as a side-effect I've drafted the attached notes to (1) offer
a tutorial for future compiler-plugin authors; and (2) share information
with those interested in learning more about the internals of scalac.
Because of these different audiences, I'm cross-posting these notes to both
the scala and scala.internals mailing lists.

Comments, extensions and corrections are welcome.

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

Kevin Wright
Joined: 2009-06-09,
User offline. Last seen 49 weeks 3 days ago.
Re: a code walkthrough of the CleanUp phase of scalac

Two pages in and I'm loving it already :)

On Tue, Nov 10, 2009 at 2:17 PM, Miguel Garcia wrote:
>
> Hi,
>
> I've been meaning for a while to get a clearer picture of the CleanUp phase
> of scalac, and as a side-effect I've drafted the attached notes to (1) offer
> a tutorial for future compiler-plugin authors; and (2) share information
> with those interested in learning more about the internals of scalac.
> Because of these different audiences, I'm cross-posting these notes to both
> the scala and scala.internals mailing lists.
>
> Comments, extensions and corrections 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: a code walkthrough of the CleanUp phase of scalac

On Tue, Nov 10, 2009 at 03:17:03PM +0100, Miguel Garcia wrote:
> Comments, extensions and corrections are welcome.

Since it still makes me kind of sad that TreeDSL was not viewed as a
universal good, and since CleanUp is probably the file upon which I
worked the hardest, could I talk you into taking a quick look at it from
before TreeDSL? Say from r18129. Then you could send another message to
the list saying something like "As a disinterested observer, I *love*
TreeDSL! I want to marry it!" You could use that quote verbatim if you
want, or adjust it a little if absolutely necessary.

Kevin Wright
Joined: 2009-06-09,
User offline. Last seen 49 weeks 3 days ago.
Re: a code walkthrough of the CleanUp phase of scalac

Heh, yeah, treeDSL rocks. :)

It's just so frustrating that we have this great way to synthesise
methods and classes and suchlike, but just can't do so because by that
time the typer has already done its thing and the errors have already
been raised...

On Tue, Nov 10, 2009 at 3:07 PM, Paul Phillips wrote:
> On Tue, Nov 10, 2009 at 03:17:03PM +0100, Miguel Garcia wrote:
>> Comments, extensions and corrections are welcome.
>
> Since it still makes me kind of sad that TreeDSL was not viewed as a
> universal good, and since CleanUp is probably the file upon which I
> worked the hardest, could I talk you into taking a quick look at it from
> before TreeDSL? Say from r18129.  Then you could send another message to
> the list saying something like "As a disinterested observer, I *love*
> TreeDSL! I want to marry it!"  You could use that quote verbatim if you
> want, or adjust it a little if absolutely necessary.
>
> --
> Paul Phillips      | Giving every man a vote has no more made men wise
> Future Perfect     | and free than Christianity has made them good.
> Empiricist         |     -- H. L. Mencken
> pal, i pill push   |----------* http://www.improving.org/paulp/ *----------
>

Miguel Garcia
Joined: 2009-06-10,
User offline. Last seen 42 years 45 weeks ago.
Re: a code walkthrough of the CleanUp phase of scalac

Paul,

No technology is perfect, although TreeDSL comes close. All right, the long
answer is: Although I have a hunch that TreeDSL is the best out there, right
now, I cannot say much more than that (no, I haven't spent nights with it).
I hope my notes however wet the appetite of the reader to learn more, and
tell the rest of the world about it.

Peace. Quoting from a previous post: "Here's a cute kitty" :P

Miguel

rytz
Joined: 2008-07-01,
User offline. Last seen 45 weeks 5 days ago.
Re: a code walkthrough of the CleanUp phase of scalac


On Tue, Nov 10, 2009 at 16:18, Kevin Wright <kev.lee.wright@googlemail.com> wrote:
Heh, yeah, treeDSL rocks. :)

It's just so frustrating that we have this great way to synthesise
methods and classes and suchlike, but just can't do so because by that
time the typer has already done its thing and the errors have already
been raised...

That's actually one point that was brought up against the treeDSL.
Generating trees was always easy, creating symbols, adding types,
entering them in Scope, and making everything available at the right
time was (and still is) hard. While treeDSL is cute, it doesn't help
much either.

 



On Tue, Nov 10, 2009 at 3:07 PM, Paul Phillips <paulp@improving.org> wrote:
> On Tue, Nov 10, 2009 at 03:17:03PM +0100, Miguel Garcia wrote:
>> Comments, extensions and corrections are welcome.
>
> Since it still makes me kind of sad that TreeDSL was not viewed as a
> universal good, and since CleanUp is probably the file upon which I
> worked the hardest, could I talk you into taking a quick look at it from
> before TreeDSL? Say from r18129.  Then you could send another message to
> the list saying something like "As a disinterested observer, I *love*
> TreeDSL! I want to marry it!"  You could use that quote verbatim if you
> want, or adjust it a little if absolutely necessary.
>
> --
> Paul Phillips      | Giving every man a vote has no more made men wise
> Future Perfect     | and free than Christianity has made them good.
> Empiricist         |     -- H. L. Mencken
> pal, i pill push   |----------* http://www.improving.org/paulp/ *----------
>

extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.
Re: a code walkthrough of the CleanUp phase of scalac

On Tue, Nov 10, 2009 at 05:00:24PM +0100, Lukas Rytz wrote:
> While treeDSL is cute, it doesn't help much either.

That is precisely the point I dispute, but I'll settle for cute. And
while maybe it doesn't help in the writing (not that I think that, but
OK) you guys must have some seriously amazing code vision if it offers
zero benefit in the reading.

Kevin Wright
Joined: 2009-06-09,
User offline. Last seen 49 weeks 3 days ago.
Re: a code walkthrough of the CleanUp phase of scalac

On Tue, Nov 10, 2009 at 4:09 PM, Paul Phillips wrote:
> On Tue, Nov 10, 2009 at 05:00:24PM +0100, Lukas Rytz wrote:
>> While treeDSL is cute, it doesn't help much either.

It works a charm if you want to modify stuff in existing methods, or
create methods that override from a superclass. It's just creating
(and then attempting to use) previously unseen methods that the
compiler starts to choke.

Looking at the way TreeDSL is used for case classes(and @BeanProperty,
and number specialisation), I would hardly say it doesn't help much!

> That is precisely the point I dispute, but I'll settle for cute.  And
> while maybe it doesn't help in the writing (not that I think that, but
> OK) you guys must have some seriously amazing code vision if it offers
> zero benefit in the reading.
>
> --
> Paul Phillips      | Appreciation is a wonderful thing; it makes what is
> Stickler           | excellent in others belong to us as well.
> Empiricist         |     -- Voltaire
> pal, i pill push   |----------* http://www.improving.org/paulp/ *----------
>

Kevin Wright
Joined: 2009-06-09,
User offline. Last seen 49 weeks 3 days ago.
Re: a code walkthrough of the CleanUp phase of scalac

On Tue, Nov 10, 2009 at 4:00 PM, Lukas Rytz wrote:
>
>
> On Tue, Nov 10, 2009 at 16:18, Kevin Wright
> wrote:
>>
>> Heh, yeah, treeDSL rocks. :)
>>
>> It's just so frustrating that we have this great way to synthesise
>> methods and classes and suchlike, but just can't do so because by that
>> time the typer has already done its thing and the errors have already
>> been raised...
>
> That's actually one point that was brought up against the treeDSL.
> Generating trees was always easy, creating symbols, adding types,
> entering them in Scope, and making everything available at the right
> time was (and still is) hard. While treeDSL is cute, it doesn't help
> much either.
>

I still have my fingers crossed that I can perform a local and
disposable invocation of namer/typer in a plugin directly after parser
(and before the "official" namer is executed). Ideally this will only
be a limited run over units where I actually need type/symbol
information and so not too costly in terms of performance.

Then I can inject methods, etc. that need type information to be
correctly generated. From the perspective of global, everything
concerned then appears to be synthesised in the AST *before* it
generates symbols and types. It goes without saying that I'll use
TreeDSL in this endeavour...

Obviously a full write-up is going to have to follow if I can make it
all work :)

>>
>>
>> On Tue, Nov 10, 2009 at 3:07 PM, Paul Phillips
>> wrote:
>> > On Tue, Nov 10, 2009 at 03:17:03PM +0100, Miguel Garcia wrote:
>> >> Comments, extensions and corrections are welcome.
>> >
>> > Since it still makes me kind of sad that TreeDSL was not viewed as a
>> > universal good, and since CleanUp is probably the file upon which I
>> > worked the hardest, could I talk you into taking a quick look at it from
>> > before TreeDSL? Say from r18129.  Then you could send another message to
>> > the list saying something like "As a disinterested observer, I *love*
>> > TreeDSL! I want to marry it!"  You could use that quote verbatim if you
>> > want, or adjust it a little if absolutely necessary.
>> >
>> > --
>> > Paul Phillips      | Giving every man a vote has no more made men wise
>> > Future Perfect     | and free than Christianity has made them good.
>> > Empiricist         |     -- H. L. Mencken
>> > pal, i pill push   |----------* http://www.improving.org/paulp/
>> > *----------
>> >
>
>

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