ada.2: spring cleaning before final pull request.
authorNicolas Boulenguez <nicolas@debian.org>
Sun, 17 Mar 2019 10:24:03 +0000 (11:24 +0100)
committerNicolas Boulenguez <nicolas@debian.org>
Sun, 17 Mar 2019 13:03:38 +0000 (14:03 +0100)
commit00c3a3c33da116e5622bd596b002de6c110af3fc
tree995027e0d39ef4dd0c5e8e58308ce3094fe8c983
parent0b4ab1a5262efc26d22f7df33fba41917c68ad03
ada.2: spring cleaning before final pull request.

Two changes require approval.

* The 'do' special becomes a built-in function similar to first. This
  small change reduces the complexity of eval.  The last evaluation
  cannot benefit from TCO, but the performance change seems invisible.

* read/eval/print acts on each item found in the input string, as if
  they were enclosed with (do ..). The guide does not specify what
  should happen to text following the first AST, and this change actually
  simplifies some things (like dealing with zero AST).
  The read-string built-in function only returns the first AST,
  as changing this would be much more intrusive.

Other changes seem straightforward.

Global:
* Ada 2020 target assignments (like +=, but more general).
* Use Constant_Indexing aspect for sequences, so that they can be
  indexed in source code like native arrays.
* consistency renamings.
  'fn' does not include built-in functions, 'function' does.
  'list' does not include vectors, 'sequence' does.

Move error handling to a separate package.
* This simplifies code everywhere else.
* Uncaught expressions now report a stack trace.

Types:
* Count allocations and deallocations, check that counts match.
* Share more code between functions and macros.

Core:
* Replace the Core.Ns function returning an array with a procedure
  (The intermediate object was preventing the reference counting code
  from deallocating some unused objects).
* Implement Prn with Pr_Str.

Printer:
* Change the profile so that the caller spares some allocations.

Reader:
* Share a single buffer of mal values between all recursions.
  This significantly reduces the stack footprint.

Steps:
* Fix implementation name (ada.2) in the startup script.
* Let environment variables trigger debugging information.
39 files changed:
ada.2/Makefile
ada.2/README
ada.2/core.adb
ada.2/core.ads
ada.2/envs.adb
ada.2/envs.ads
ada.2/err.adb [new file with mode: 0644]
ada.2/err.ads [new file with mode: 0644]
ada.2/printer.adb
ada.2/printer.ads
ada.2/reader.adb
ada.2/reader.ads
ada.2/step1_read_print.adb
ada.2/step2_eval.adb
ada.2/step3_env.adb
ada.2/step4_if_fn_do.adb
ada.2/step5_tco.adb
ada.2/step6_file.adb
ada.2/step7_quote.adb
ada.2/step8_macros.adb
ada.2/step9_try.adb
ada.2/stepa_mal.adb
ada.2/types-atoms.adb
ada.2/types-atoms.ads
ada.2/types-builtins.adb
ada.2/types-builtins.ads
ada.2/types-fns.adb [moved from ada.2/types-functions.adb with 57% similarity]
ada.2/types-fns.ads [moved from ada.2/types-functions.ads with 86% similarity]
ada.2/types-lists.adb [deleted file]
ada.2/types-mal.adb
ada.2/types-mal.ads
ada.2/types-maps.adb
ada.2/types-maps.ads
ada.2/types-sequences.adb [new file with mode: 0644]
ada.2/types-sequences.ads [moved from ada.2/types-lists.ads with 85% similarity]
ada.2/types-symbols-names.ads
ada.2/types-symbols.adb
ada.2/types-symbols.ads
ada.2/types.ads