-
Notifications
You must be signed in to change notification settings - Fork 5
Description
I'm more convinced that parsing and type operations can and should be separated. Parsing involves the environment and some details about how the implementation deftype works.
Furthermore, for a more flexible system with possible extended specifiers, we'd want to store information about specifiers in the environment, where it conceptually belongs, rather than how we do it now with methods on symbol-specifier-ctype and such.
So here's what I'm thinking. Conceptually, type specification works a bit like form evaluation. You have macros from deftype. You have "functions" like cons, that don't need the environment because they can accept "arguments" of already specified types. And you have "special operators" like array that "evaluate" some subforms and don't "evaluate" others.
The environment can include bindings of type specifiers as either special operators, macros, or functions. All of these can just be ordinary functions. The functions for macros are just type expanders, so probably a function of a specifier and an environment that returns an expanded specifier. The functions for functions have the lambda list of the type specifier, so for example the function for cons would take two arguments, both already-parsed specifiers. And the functions for special operators take a specifier and an environment and return the parsed specifier. This way the system could be actually totally separate from ctype as the functions could return whatever other kind of parsed specifier.
Parsing should also do caching. Caching is somewhat nontrivial since caches may have to be partially invalidated when new classes or types are defined, and because they should be thread safe.