Stuff on the local methods branch

Maurizio Cimadamore maurizio.cimadamore at
Mon Jan 6 23:24:08 UTC 2020

On 04/01/2020 17:17, Jesper Steen Møller wrote:
> Basically, LambdaToMethod is really hard to understand and reason about from trying to do two things at once (in two passes even, counting the LambdaAnalyzerPreprocessor which shares state with the outer pass).
> Can't we just have a separate pass ("LowerLocalMethods") that takes care of local methods, like the separation between lambdas and inner classes? We should be able to mark if local methods are used during parsing, so we can skip the lowering if not needed.
Hi Jesper (great work!)

I agree that LambdaToMethod was already complicated to begin with and 
now it gotten worse (I'm guilty of that, as I wrote the first hacky 
patch). Splitting local methods into their own phase seems like a good 
idea - initially I went for LambdaToMethod because this was a quick and 
dirty experiment and I wanted to reuse as much code as possible. That 
said, if we do split into a separate phase, we should try not to 
reinvent solution for problems we have already solved (e.g. find the set 
of captured entities). And my fear is that you need a lot of what the 
analyzer preprocessor currently do; I'd be happy to be proven wrong - if 
not, we could always find other ways to reuse the preprocessing info 
from multiple stages.


More information about the amber-dev mailing list