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

two code walkthroughs less to go: UnCurry and Specialize

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

Hi,

As a by-product of trying to understand the Scala compiler I keep making
notes. It's a form of catarsys.

This time is the turn of UnCurry (10% covered, or feels like so) and
SpecializeTypes (eh ... less than 10%).

The notes go attached to motivate others to share even more notes. 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: two code walkthroughs less to go: UnCurry and Specialize

On Tue, Nov 24, 2009 at 05:16:54PM +0100, Miguel Garcia wrote:
> As a by-product of trying to understand the Scala compiler I keep
> making notes. It's a form of catarsys.

Whatever your motivation, I hope you keep doing it. I've often thought
I ought to be writing little documents like that, but as yet it's never
been more tempting than writing more code.

Kevin Wright
Joined: 2009-06-09,
User offline. Last seen 49 weeks 3 days ago.
Re: two code walkthroughs less to go: UnCurry and Specialize
Keep up the good work there!  This is fantastic stuff.

On Tue, Nov 24, 2009 at 4:25 PM, Paul Phillips <paulp@improving.org> wrote:
On Tue, Nov 24, 2009 at 05:16:54PM +0100, Miguel Garcia wrote:
> As a by-product of trying to understand the Scala compiler I keep
> making notes. It's a form of catarsys.

Whatever your motivation, I hope you keep doing it.  I've often thought
I ought to be writing little documents like that, but as yet it's never
been more tempting than writing more code.

--
Paul Phillips      | It is hard to believe that a man is
Stickler           | telling the truth when you know that you
Empiricist         | would lie if you were in his place.
pull his pi pal!   |     -- H. L. Mencken

Iulian Dragos 2
Joined: 2009-02-10,
User offline. Last seen 42 years 45 weeks ago.
Re: two code walkthroughs less to go: UnCurry and Specialize
I had a quick look at the document about specialization. Everything is accurate and I think most of what's there applies to other phases as well (transformers and typing transfomers, for example).
Regarding the mysterious comment, the key thing to note is that there are two transformations at work: one on types (InfoTransformers) and one on terms. The first one is applied to any symbol in the Scala compiler, and it has it's own infrastructure (see InfoTransfomers). It "simply" adds symbols (like classes and extra public methods) for the specialized definition it encounters, whether or not their source code is compiled in the current run. The term transformation is applied (of course) only to the trees that are actually compiled, and consists of creating trees for the new definitions added "earlier" that correspond to currently compiled classes. Info transformers are lazy, meaning that a symbol, when asked for its type, looks at the current phase and if necessary applies any registered transformers on that type until it is in line with the current phase. The comment simply makes this call to make sure the specialized info transformer has been applied (and therefore new symbols have been entered in the symbol table, so that trees can be attached to them).
I hope it makes sense.
iulian

On Tue, Nov 24, 2009 at 5:16 PM, Miguel Garcia <miguel.garcia@tuhh.de> wrote:

Hi,

As a by-product of trying to understand the Scala compiler I keep making notes. It's a form of catarsys.

This time is the turn of UnCurry (10% covered, or feels like so) and SpecializeTypes (eh ... less than 10%).

The notes go attached to motivate others to share even more notes. Comments are welcome.


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



--
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais

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