4 ms·
My understanding is that the "traditional way" is based on a number of "passes". In my head it looks like: 1) Parse all the code. 2) Assemble the set of all ty
by oconnor663 7y ago
My understanding is that the "traditional way" is based on a number of "passes". In my head it looks like:
1) Parse all the code.
2) Assemble the set of all types.
3) Typecheck all the code.
4) Translate the parse tree into unoptimized machine code.
5) Optimize all that machine code.
This is oversimplifying things, as in practice there are intermediate representations between the parse tree and the machine code. And optimization itself usually involves multiple passes of different kinds. But anyway, the key point here is that, if you change any of the code, you have to run all of these steps all over again. (I'm oversimplifying again. Maybe you only have to rerun them for a given "compilation unit", but that's bad enough.) This is the opposite of what you want for an IDE. There, you want to say "I just changed this function. Please recompile the absolute minimum necessary to tell me whether my change works." To answer a question like that efficiently, you have to rearchitect the whole compiler from being pass-based to being query-based, so you can give it instructions like "please update the type of just this expression".