Implementation for implicit member chains

I've created a PR that implements implicit member chains here. If anyone has the opportunity to look it over and offer feedback I'd really appreciate it.

A couple big questions I have are:

  1. What are the practices around storing information in the AST versus computing it at runtime? For accessing the base of these "member chains" I added a new ChainBase property to the AST on several expressions, but it isn't strictly necessary—we could just drill down through the chain whenever we want to get to the base. For long (long) chains this would obviously be inefficient, but is that enough of a concern to justify bloating the AST? I imagine in practice these chains will not be longer than a few members.

  2. In the type checker, I couldn't come up with a way of keeping track of the type of the base of a chain other than adding a new map on ConstraintSystem and Solution to associate the UnresolvedMemberExprs with their base type since we now need to pull out the base type at arbitrary points in the constraint generation process, rather than just when generating constraints for the UnresolvedMemberExpr itself. Does this seem like an appropriate use case for adding such a map?

Obviously any other feedback on the broad approach or minutiae of the implementation is very welcome too!

3 Likes
Terms of Service

Privacy Policy

Cookie Policy