Commit Graph

4 Commits

Author SHA1 Message Date
1f642b9739 Change if function stack ordering, add some basic math ops to Int, add factorial example
* `if` function stack ordering is changed to use condition, if-false,
  if-true (bottom to top). This is so we can pass a value on top of the
  stack directly to a new `if` in a condition, so we don't have to store
  a new value in a new variable.
* Add __splat__ and __minus__ functions to Int
* Add * and - builtins, which call the __splat__ and __minus__ functions
  of the top stack item, respectively.
* Add factorial example because now factorials are possible with this
  skeleton implementation, albeit a little hacky with the recursion.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-02-11 11:10:14 -08:00
cb9e09064a Implement __bool__, add if builtin, vtable imporvements
* `if` builtin is the big one here - branching! Yay!
* The `if` builtin requires __bool__ to be implemented for things. This
  is added for all builtin objects.
* Vtables have slightly better ergonomics.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-02-04 17:29:41 -08:00
67054b2c84 Update branching example to use new syntax
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-16 16:49:09 -08:00
90f27a4108 Add branching and more coherent method of function calls
We're turing-complete, babey!

* Call stack for functions now differentiates between native and quote
  calls
* Better API for builtin functions allowing for more control
* Example showing off branches

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-12 21:49:41 -08:00