1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-17 16:47:22 +03:00
mal/ada.2
Nicolas Boulenguez 14ab099cea gensym: hide the counter in an environment, define inc in stepA.
tests: check that `inc` is present in stepA.
nasm: split lines in mal_startup_string for readability.
objpascal: remove obsolete .orig file
swift: remove an unneeded line in template
swift4: remove duplicate definition of `or` macro
2019-05-11 16:37:26 +02:00
..
core.adb ada.2 switch back do from built-in function to special form 2019-05-08 03:13:47 +02:00
core.ads Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
Dockerfile ada.2: add Dockerfile from kanaka 2019-03-17 14:15:41 +01:00
envs.adb Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
envs.ads Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
err.adb Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
err.ads Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
garbage_collected.adb Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
garbage_collected.ads Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
Makefile Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
printer.adb Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
printer.ads Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
reader.adb Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
reader.ads Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
readline.adb ada2: rename to ada.2 2019-03-10 01:25:07 +01:00
readline.ads Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
README Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
run ada2: rename to ada.2 2019-03-10 01:25:07 +01:00
step0_repl.adb Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
step1_read_print.adb Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
step2_eval.adb Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
step3_env.adb Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
step4_if_fn_do.adb ada.2 switch back do from built-in function to special form 2019-05-08 03:13:47 +02:00
step5_tco.adb ada.2 switch back do from built-in function to special form 2019-05-08 03:13:47 +02:00
step6_file.adb ada.2 switch back do from built-in function to special form 2019-05-08 03:13:47 +02:00
step7_quote.adb ada.2 switch back do from built-in function to special form 2019-05-08 03:13:47 +02:00
step8_macros.adb ada.2 switch back do from built-in function to special form 2019-05-08 03:13:47 +02:00
step9_try.adb ada.2 switch back do from built-in function to special form 2019-05-08 03:13:47 +02:00
stepa_mal.adb gensym: hide the counter in an environment, define inc in stepA. 2019-05-11 16:37:26 +02:00
types-atoms.adb Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
types-atoms.ads Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
types-builtins.adb Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
types-builtins.ads Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
types-fns.adb Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
types-fns.ads Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
types-macros.adb Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
types-macros.ads Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
types-maps.adb Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
types-maps.ads Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
types-sequences.adb Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
types-sequences.ads Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
types-strings.adb Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
types-strings.ads Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
types.adb Clarify and optimize ada.2. 2019-05-02 21:19:34 +02:00
types.ads Clarify and optimize ada.2. 2019-05-02 21:19:34 +02: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)