Closed alberdingk-thijm closed 3 years ago
A topsort seems like a good solution. It gets around the problem of accidentally introducing recursion into the language.
Probably related to #33 since this is something we'll want to consider when doing modules.
Right now, nv expects users to define anything they reference before it is called. The following code snippet does not compile:
It would be convenient if nv could instead allow its top-level declarations in arbitrary order, as many other modern languages do.
One possible way of allowing this might be to topologically sort the declarations after parsing. If a cycle occurs due to 2 or more functions depending on each other, then an error can be thrown.