Update build system, syntax and library calls for zig 0.13.0.
Rewrite the build system so that the steps can build separately. Drop
intermediate symbolic links (unneeded complexity, confusing
timestamps).
Build with debugging options, this is a toy project full of memory
leaks.
Declare the allocators as global variables instead of passing and/or
storing always the same reference everywhere for no benefit.
Make apply_function a global variable instead of adding a reference to
EVAL in each function.
Pass arguments as a slice instead of using a different type for each
argument count.
There is no point in renaming default errors.
Remove a lot of reference counting and some indirection levels.
This fixes the current segmentation faults.
Create each object as soon as possible and use errdefer so that it is
deallocated if an exception occurs when computing its elemements.
Use a global variable to convey a MAL object alongside a thrown error.
Remove the unused logging_alloc module (but add a debug_alloc boolean
in types.zig).
In step4 the following fails to return 0:
```
(let* [b 0 f (fn* [] b)] (let* [b 1] (f)))
```
Just use the initEnv initializer in steps 3 and 4 (following the same
pattern used by step 5 on onwards).
This version is hopefully more readable.
It removes the specific exception for blank lines, which is not
required and obfuscates the repl loop for little benefit.
Remove unused dependencies.
Import explicit lists for clarity.
Avoid module::function prefixs, as some modules will be renamed
(critic: modules must be capitalized).
Add an explicit export list to core.pm, so that all symbols are not
exported by default.
Introduce a pr_list function, which is convenient and removes the need
to rename _pr_str (critic: a leading underscore means a private
function).
Uppercase core::ns (critic complains about lowercase exported
variables).
While at it, convert values to MAL functions on the fly.
Implement env->get with a loop instead of a recursion, for readability and efficiency.
Simplify mal_readline and avoid storing empty lines in the history.
Fix (false? 1) and (true? 0).
Change the type of the env.{find,get,set} key to a raw string.
Merge eval-ast into EVAL.
Implement DEBUG-EVAL.
Prevent defmacro! from mutating the original function.
The original motivation is to fix the new (= nil ()) and
core_apply_accepts_macros tests.
Improve speed and warnings with byte compilation.
mal/core.el:
Wrap core functions during the loop in main, instead of writing the
conversion in each line of core-ns.
Use apply built-in concatenation of last argument.
Move handling of metadata to types.el.
mal/env.el:
Represent environments as cons cells instead of vectors.
mal/func.el:
Merged into types.el, it is not a special case anymore.
mal/printer.el:
Add macro case.
Define a pr-join helper for sequences and core.el.
mal/reader.el:
Rename the tokens local variable in reader.el (compiler warning).
mal/types.el:
Use type-specific accessors returning nil for the wrong type
(structural pattern matching would be better, but is too slow).
Represent native types directly when possible, and inline some trivial
accessors.
Use dedicated records instead of vectors.
Implement metadata only when required.
Represent keywords as strings (easyer, no counterpart).
run:
Run byte-compiled version.
steps:
Backport good ideas from stepA to step1, reducing the diff between
steps for future maintenance.
Implement 'do with a simple iteration (without map and butlast).
Make the repl-env local to main (compiler warning).
Make the code more idiomatic
* prefer loop over recursion (search in environments)
* declare variable and reassign them when convenient (exit of the TCO loop)
* car cdr cadr and so on instead of nth
* remove various vector <-> list conversions.