Programs should be augmented with type dictionaries

Bug #710495 reported by Matt Giuca
6
This bug affects 1 person
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

Revision history for this message
Matt Giuca (mgiuca) wrote :

Fixed in trunk r1196.

Changed in mars:
status: In Progress → Fix Committed
Matt Giuca (mgiuca)
Changed in mars:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.