1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-20 18:18:51 +03:00
mal/impls/ada.2
Nicolas Boulenguez c9f7b5a1f8 dockerfiles: improve consistency, link python to python3
Explictly select python 3.  The `python2` and `python` packages will
be removed from Ubuntu.  Until each call site is fixed, install a
/usr/local/bin/python symbolic link as a non-intrusive work-around
(.deb packages do not interfer with /usr/local).

Add an explicit maintainer for bbc-basic.

Undo some cosmetic changes in order to reduce the global diff, this
merge request will probably be sqashed before acceptance.

Move lib{readline,edit}-dev out of the generic part.

Use existing .deb packages for GHDL and vim.
2024-08-05 17:02:34 -05:00
..
core.adb ada.2: stop supporting metadata for atoms 2021-12-11 10:06:52 -06:00
core.ads Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
Dockerfile dockerfiles: improve consistency, link python to python3 2024-08-05 17:02:34 -05:00
envs.adb Merge eval-ast and macro expansion into EVAL, add DEBUG-EVAL 2024-08-05 11:40:49 -05:00
envs.ads Merge eval-ast and macro expansion into EVAL, add DEBUG-EVAL 2024-08-05 11:40:49 -05:00
err.adb Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
err.ads Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
garbage_collected.adb Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
garbage_collected.ads Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
Makefile Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
printer.adb Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
printer.ads Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
reader.adb Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
reader.ads Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
readline.adb Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
readline.ads Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
README Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
run Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
step0_repl.adb Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
step1_read_print.adb Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
step2_eval.adb Merge eval-ast and macro expansion into EVAL, add DEBUG-EVAL 2024-08-05 11:40:49 -05:00
step3_env.adb Merge eval-ast and macro expansion into EVAL, add DEBUG-EVAL 2024-08-05 11:40:49 -05:00
step4_if_fn_do.adb Merge eval-ast and macro expansion into EVAL, add DEBUG-EVAL 2024-08-05 11:40:49 -05:00
step5_tco.adb Merge eval-ast and macro expansion into EVAL, add DEBUG-EVAL 2024-08-05 11:40:49 -05:00
step6_file.adb Merge eval-ast and macro expansion into EVAL, add DEBUG-EVAL 2024-08-05 11:40:49 -05:00
step7_quote.adb Merge eval-ast and macro expansion into EVAL, add DEBUG-EVAL 2024-08-05 11:40:49 -05:00
step8_macros.adb Merge eval-ast and macro expansion into EVAL, add DEBUG-EVAL 2024-08-05 11:40:49 -05:00
step9_try.adb Merge eval-ast and macro expansion into EVAL, add DEBUG-EVAL 2024-08-05 11:40:49 -05:00
stepa_mal.adb Merge eval-ast and macro expansion into EVAL, add DEBUG-EVAL 2024-08-05 11:40:49 -05:00
types-atoms.adb ada.2: stop supporting metadata for atoms 2021-12-11 10:06:52 -06:00
types-atoms.ads ada.2: stop supporting metadata for atoms 2021-12-11 10:06:52 -06:00
types-builtins.adb Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
types-builtins.ads Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
types-fns.adb Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
types-fns.ads Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
types-maps.adb Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
types-maps.ads Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
types-sequences.adb Change quasiquote algorithm 2020-08-11 01:01:56 +02:00
types-sequences.ads Change quasiquote algorithm 2020-08-11 01:01:56 +02:00
types-strings.adb Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
types-strings.ads Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
types.adb Merge eval-ast and macro expansion into EVAL, add DEBUG-EVAL 2024-08-05 11:40:49 -05:00
types.ads Merge eval-ast and macro expansion into EVAL, add DEBUG-EVAL 2024-08-05 11:40:49 -05:00

Comparison with the first Ada implementation.
--

The first implementation was deliberately compatible with all Ada
compilers, while this one illustrates various Ada 2012 features:
assertions, preconditions, invariants, initial assignment for limited
types, limited imports...

The variant MAL type is implemented with a discriminant instead of
object-style dispatching.  This allows more static and dynamic checks,
but also two crucial performance improvements:
* Nil, boolean, integers and pointers to built-in functions are passed
  by value without dynamic allocation.
* Lists are implemented as C-style arrays, and can often be
  allocated on the stack.

Another difference is that a minimal form of garbage collecting is
implemented, removing objects not referenced from the main
environment. Reference counting does not seem efficient even for symbols,
and never deallocates cyclic structures. The implementation collects
garbage after each Read-Eval-Print cycle. It would be much more
difficult to collect garbage inside scripts. If this is ever done, it
would be better to reimplement load-file in Ada and run a cycle after
each root evaluation.
It is possible to execute the recursion marking references in parallel
with the recursion printing the result, which does not modify anything
and ignores the reference marking. This works but is less performant
than sequential execution even with Linux threads and a single task
initialized at startup.
Each pointer type goes on using its own memory pool, enabling better
performance when the designated subtype has a fixed size.

The eventual performances compete with C-style languages, allthough
all user input is checked (implicit language-defined checks like array
bounds and discriminant consistency are only enabled during tests).

Debugging
--

Uncaught exceptions are reported with an execution trace (excluding
TCO cycles).  This has become possible in step9, but has been
backported to former steps as this is really handy for debugging.

Some environment variables increase verbosity.
# dbgread= ./stepAmal     trace reader recursion
# dbgeval= ./stepAmal     trace eval recursion (including TCO)