google / mangle

Apache License 2.0
1.09k stars 38 forks source link

Stratification during analysis #21

Open vlad-arista opened 1 year ago

vlad-arista commented 1 year ago

Is there a reason why stratification is done during evaluation rather than analysis? It seems redundant to stratify every time given that analysis.ProgramInfo is most commonly produced by Analyze* calls.

burakemir commented 1 year ago

I agree that needless work is done when one has does multiple evaluation phases with the same program. I will add entry points that let clients call evaluation with a previously stratified program.

Also, stratification can be considered a form of semantic analysis, although it seems different from name resolution and type checking.

Are you suggesting that analysis should always perform stratification and include the result in analysis.ProgramInfo?

vlad-arista commented 1 year ago

It would seem convenient to have stratification as part of some preprocessing step, because like name resolution and type checking, it also detects invalid programs and it's also required for all evaluation strategies I can think of, so it's not optional. Additionally, I don't know if stratification by itself (outside of evaluation) is useful, so probably shouldn't necessarily be part of the public API. But we can deal with calling Stratify after Analyze.