Open krame505 opened 3 years ago
Ugh. Thanks for ruining my Saturday evening... :)
So the proposal is to move end
, but not do this larger restructuring you are describing at the end?
Yeah, we already did this as a part of the origin tracking patch (settled on the syntax attachNote note on e end
.)
This restructuring is a mostly hypothetical exercise, which I don't recommend we actually do.
Ok sounds good. Thanks.
This is basically what we outlined in the COLA reflection paper, but the practical implications are much more annoying than I previously thought.
For example, @602p wanted to move the
end
keyword fromsilver:modification:let_fix
tosilver:definition:core
to use this in host-language concrete syntax for origin tracking (where it probably belonged in the first place. This is a reserved keyword and is used by several extensions and modifications, some of which are importing the let modification just to use this keyword.)However, the existing build of Silver uses
Silver_Expr { ... }
syntax literals in a number of places, many of which includelet
expressions and other syntax that uses theend
keyword. So if one attempts to rebuild Silver normally after making this change, thesilver:metatranslation
library reflects the abstract syntax trees of these literals and then attempts to translate them into Silver code according to the current compiler's abstract syntax - however the new abstract syntax that is being compiled doesn't match that of the current compiler (the names have changed), so the build fails during the initial pass.So the problem is that when bootstrapping this sort of refactor, we need to generate code for concrete syntax literals that matches the abstract syntax that we are currently compiling, rather than what we got from
reflect
. In the case of moving theend
keyword, the process that I ended up following was./self-compile --clean && cp build/silver.composed.Default.jar jars/
End_kwd
tosilver:definition:core
./self-compile
again to check that nothing broke./deep-rebuild
We (I) will need to deal with this again, but on much worse scale when #152 finally gets done, moving compiler internals under
silver:
tosilver:compiler:
, since the full names of everything(!) will change at that point.Note that this isn't a problem in the case of e.g. silver-ableC because there we have everything sorted out into a nice dependency graph, such that while we would like to just self-compile a change with the latest silver-ableC jars, we can always fall back to bootstrapping (abit slowly) from unextended Silver. One possible fix here would be to enforce the same sort of separation in Silver such that there would be 3 (or more) classes of Silver features/extensions:
Then only 1 would need to be "permanently" bootstrapped (and could be rebuilt using the jars from 1, 2 or 3) while 2 and 3 can always be incrementally rebuild from the jars corresponding to just the features from 1. The obvious downsides of this would be
deep-rebuild
, so compile times would suffer. This could be mitigated by makingdeep-rebuild
start using the jars from 3 and add adeeper-rebuild
that does the full bootstrap which we only use for this sort of refactor or when things break.So for these reasons I'm not in favor of making this change. I'm not sure there really is a nice solution here, but one option when we are performing big refactors like #152 is to follow the same procedure as above but instead of modifying
silver:metatranslation
, use the term rewriting library on the meta-translatedExpr
s to replace all names matching the old grammars with the new ones.Anyway this issue (rant?) has gone on a lot longer than I intended, and this is mostly for me to reference in the future if this issue pops up again. So I'll stop here, but I am open if anyone else has thoughts on this problem.