Types in Narcissus
Proposal for Adding Types to Narcissus
There are a couple of things that need doing:
- Keeping track of declared types.
This can be done through another array (or map) in the CompilerContext types = . As a type becomes complete (has no references to incomplete types) it'll be put in the map. Incomplete types will be put on a seperate list, and if we reach the end of a compilation unit with any incomplete types, throw an error. I think that we'll need another structure to keep track of the structure of a type (e.g., for function types, it'll keep track of the parameters and the return values).
- We need to map variable names and function names to the types given in their annotations.
This should be easily done by adding this information to the funDecls and varDecls arrays (and making those maps between names and types).
Once the parser knows how to pass the types through to the execution context, we can start implementing type checking and some of the other, more interesting proposals.