radian628 / desmoscript

Desmos scripting language and successor to LISPsmos.
101 stars 8 forks source link

Redesign import system. #7

Closed radian628 closed 1 year ago

radian628 commented 1 year ago

As it currently stands, Desmoscript's import system is broken: Files cannot be imported without an accompanying namespace. Furthermore, using a file in multiple places leads to multiple copies of that file being instantiated. The simplest solution would be to use a C-style header/source distinction, but this leads to a lot of boilerplate and thus I will not pursue it.

I'll make several changes to fix the import system:

  1. Don't check for duplicate identifiers (beyond ones in the same file), undefined identifiers, et cetera until after linking occurs.
  2. Cache all imported files and compile them all in isolation.
  3. Somehow find a way to make globally unique identifiers across multiple source files. This shouldn't be too bad once I am at the compile step and have all the linked files fully loaded.

I might have to rewrite the entire compiler from the ground up. This will also allow me to handle several poor design decisions, so it might be the best option. Everything past the AST phase (semantic analysis and compilation) will have to go, however.

radian628 commented 1 year ago

Design changes to make: