Toxaris / pts

Interpreter for functional pure type systems.
BSD 3-Clause "New" or "Revised" License
21 stars 7 forks source link

Improve name representation #89

Open Toxaris opened 9 years ago

Toxaris commented 9 years ago

Currently, most names a string from the user program plus an integer for freshening. We fear that comparing the strings takes too much time.

We discusses some ideas for improvement:

Toxaris commented 9 years ago

On my way home, I thought of another option for interning the names: Since all names are part of the user program, they are all created in the parser, and the parser could intern the name. The necessary state can be kept as Parsec user state.

That means that next to the string, we store an id of type Int with the following property: If and only if the ids of two names are equal, their strings are equal. The Eq and Ord type classes would use the id and never look at the string. The Pretty type class would use the string and never look at the id. We could even use an IntMap for environments.