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.
Use plain LUA strings as keys in environments.
Search outers environments with a loop.
Remove the now unneeded Env:find trick.
Let DEBUG-EVAL show the contents of all outer environments but repl_env.
Check the whole code with flake8, pylint and mypy.
Report all possible errors with extensive context.
Demonstrate iterators, decorators, functional tools, chain maps,
dataclasses, match statements, assignments expressions.
Implement environments with python chain maps.
Rewrite the reader without external dependencies (but inspired by the
ptk library). The motivation was that no external library is fully
type-checked for now.
Avoid name clashes when possible (print, read, readline, types).
Write the readline history file at exit, not after each prompt.
Replace printer.pr_str as methods of MAL objects. This is idiomatic
python, and improves the error reporting.
Change some representations so that the python equality matches the
MAL equality. The recursion is now implicit.
Remove -O from ./run. It took me a while to understand that run-time
assertions were disabled! MAL is about development, not performance.
Dispatch the special forms from a dict, for readability (pylint
rightfully complains that there are too many return statements in
eval_()).
Copy the recursion overflow fix, the python interaction from the first
python implementation.
Add tests detecting that nil false 0 () [] "" are distinct, and that 0
() are not False when tested (in python False == 0 and an empty
container is tested ).
Add tests checking that metadata does not affect equality (they do
with a naive python dataclass).