-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactoring inexpr
#826
Comments
I think that this looks really nice! The name is fine by me, but an alternative could also be W.r.t. smap, it feels more prone to human error since one may miss to include a check for contained declarations, unlike now when it is expressions all the way down. I guess you might want something like an Since the goal of this is to be able to share more code between mlang and mexpr, an alternative could be to instead embed Expr's in Decl's, such as |
It's not necessarily strictly declaring something, it would include |
We should also include |
This change would likely also make compilation from MLang to MExpr more elegant. In the current situation where we have contructors such as
|
We have a decent amount of code needing to traverse
Expr
s withinexpr
fields differently (often to traverse the "spine" of a program), as well as a good amount of overlap betweenExpr
andDecl
of themlang
ast. I think we could address both of these in one go.Core idea: introduce a new term
TmIn
representing anything with aninexpr
:At this point everything that currently has an
inexpr
can be replaced by usage of this term and aDecl
.TmIn
is essentially a kind of sequencing construct, for putting something with a side-effect before an expression, for a very broad definition of side-effect:TmLet
TmRecLets
TmType
TmConDef
TmExt
TmUtest
(the field is callednext
here, notinexpr
)Adding new terms of this kind would not make spine traversal incorrect, because
TmIn
would already be covered by such code. I also strongly suspect that there are points in the compiler (or one of the satellite projects) that miss at least one case here, because it would likely produce fairly subtle errors most of the time.This should mean that we can share more code between
mexpr
andmlang
, because we can presumably use exactly the same code to handle aDecl
and then only handle the sequencing inTmIn
.Drawbacks:
smap_Expr_Expr
and co. will almost certainly have to include ansmap_Expr_Decl
as well, unless we decide that the former should call the latter automatically, which seems inconsistent.match ... in
syntactic sugar becomes the only thing in the concrete syntax that hasin
and does not become aTmIn
, which goes slightly counter to the idea that the AST should be mostly obvious from the concrete syntax.The text was updated successfully, but these errors were encountered: