-
Notifications
You must be signed in to change notification settings - Fork 0
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
Compiling data #1
Comments
Of the "less critical" features, I'd like not to give up methods. I still have hope that Pyret can be used to bridge over to an OO intro course, and I don't want to lose dynamic dispatch. For the position-vs-named debate: Using records requires that we store a mapping from positions to names, or have a method that returns all fields in their proper order. This latter is what Pyret currently does. If we use flat arrays, then the name-to-position mapping is just a classic vtable, so I don't see why that's a "total non-starter". (OO languages do rely on static layout information to de-virtualize the field lookups, by knowing statically what offset the fields will appear within the object layout.) |
@blerner your parenthetical is what I'm getting at. If all we can do is what Pyret currently does, then Bucklescript's representation of values isn't helping much. One of the main reasons to try BS is to figure out what it takes to drill down to the BS representations, because they are battle-tested and known-fast. If we are building string-based vtables atop them... that's a non-starter for this approach. So my observation here is that, on something pretty fundamental, I'm concerned that the BS representations will require too much encoding already. |
Note that if we had Pyret's type information here, we could rely on static layout information to do this well. The issue is that for the super-quick idea of assuming Pyret<->OCaml will be close enough to get going quickly, it already seems like we want Pyret-specific static information, not just OCaml-style static information. |
Pyret supports data values with:
cases
The above three features are critical.
data
supports other features as well, like:These are less critical. But the first three are fundamental to Pyret and curricula that use it, so a design must accommodate them, or fundamentally change Pyret.
In choosing a representation, we have the following tensions:
type
into flat arrays with minimal, type-local tag information (integers representing the variant the value came from to compilematch
expressionscases
is positional and name-agnostic, just like OCaml ADTs and OCaml'smatch
At the very least, it seems we need to put extra metadata into the values created by
data
to track their constructor name to allow for pretty printing.The positional-vs-name debate is more vexing, because:
cases
expressionmatch
expression. A generic dynamic solution could redirect through a dictionary stored in metadata to find the right position for the field, but this seems like a total non-starter.Suggestions welcome, I think I may just need to be jolted into thinking outside the box here.
The text was updated successfully, but these errors were encountered: