|
Enables definition of a recursive function through defining a base case
using an `if` statement. Previously, doing this would produce compilable
code, but running the product executable would cause a stack overflow,
since the executable would attempt to evaluate both sides of the branch.
Making the `if` statement a built-in part of the language is a bit
crude, but is simple and works. Maybe, if time allows, this will be
revisited.
|
|
Functions can now be defined using the "def" construct. A "main"
function has to be defined for LLVM to compile the program.
Recursive function definitions are not supported, since all values are
eagerly evaluated, causing infinite recursion of the non-base case.
Recursive definitions can be supported either by including an if
primitive that does not evaluate both sides, or by implementing support
for lazy evalution. I'm interested in exploring the latter, but will
probably implement the former for now.
Similar to the if primitive above, the def primitive is currently an
implementation which could potentially be altered into a function that
manipulates meta-variables at compile time. This would require
compile-time evaluation of functions, which would be really cool, but is
also superfluous to the current goal. I might return to this idea after
I'm happy with the base implementation of the language.
|