Programs should be augmented with type dictionaries
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mars |
Fix Released
|
High
|
Matt Giuca |
Bug Description
The current interpreter implements the 'show' and 'eq' built-ins by virtue of the fact that values at runtime are dynamically-aware of their own types. Therefore, the different show and eq implementations required by each type are simply implemented by switching over the type, and (for showing user-defined types), by making up the representation on the spot. For instance, a List node Cons(1, Nil) internally keeps a string "Cons", so the string "Cons(1, Nil)" can be created at runtime.
A "real" back-end (such as the in-progress LLVM backend) has no such luxury. At runtime, a value such as Cons(1, Nil) is represented simply as a tag and two pointers -- the string "Cons" doesn't appear anywhere in the program.
Therefore, we need a completely different approach, which is to use type dictionaries (vtables) containing 'show' and 'eq' implementations for all types, and pass them wherever a type is unknown (polymorphic). This might as well be implemented for all back-ends, since the implementation is so different it would be tricky to support both a typedict and non-typedict version of the code.
This is a blocker on bug #690006, the LLVM back-end.
Related branches
Changed in mars: | |
status: | Fix Committed → Fix Released |
Fixed in trunk r1196.