On Wed, May 20, 2015 at 12:24 PM, Matt Oliveri <atma...@gmail.com> wrote:
> On Wed, May 20, 2015 at 1:44 PM, Jonathan S. Shapiro <s...@eros-os.org> > wrote: > > > The second approach would force us to do something like: > > > > type AST = > > ... > > and Expr = > > | MulExpr of AST * AST > > > > where there is a known relationship between the parent node type and the > > allowed child node types, but we don't attempt to capture or check them > > statically. This is basically what BitC v0 is doing with ASTMaker. We > > describe something similar to a GADT in ASTMaker, and generate a sanity > > checking function that runs over the AST. We could also (but currently do > > not) generate "builder" helper functions to check that the tree is > composed > > correctly. > > > > I can do that, of course, but it seems inconsistent with the spirit of > > things. > > I see that it'd be easier, more efficient, and more reliable if we > could express it in the type. I think it's mostly better to express things statically, but not 100% better. There are cases where it's useful to re-write a subtree and then whack the variant part in place so that you don't have to rewrite parent nodes recursively (i.e. upwards), and then run the sanity checker to make sure you haven't boogered anything. But I'm not sure those cases are essential, and they aren't common. shap
_______________________________________________ bitc-dev mailing list bitc-dev@coyotos.org http://www.coyotos.org/mailman/listinfo/bitc-dev