Use raw or multiline string litterals to make some hard-coded strings
more readable.
Replace some lambda constructs with more idiomatic generator
expressions, removing several temporary sequences (conversions,
contatenations, slices, arguments).
Replace definitions with assignments when possible.
Replace most python2/3 wrappers with code compatible with both
versions. Use a non-printable ASCII characters instead of Unicode
characters (in order to avoid unicode in python2).
core:
Close file open by 'slurp' after reading.
coll_Q: remove as obsolete.
conj: do not preserve metadata.
env:
Replace find with an optional argument to get.
Search in outer environments with a loop instead of a recursion.
(python is not intended for large recursions).
readline:
Copy the example from the docs.
Write the history once.
mal_types:
clone: copy.copy() everything except callables.
functions: construct fn* functions in steps, where they are used
(there was no encapsulation anyway)
Derive List and Vector from tuple, which is more efficient than list
for immutable structures. Remove the need for __getitem__ stuff.
maps: provide an asPairs iterator.
printer:
Introduce a pr_list helper like many other implementations.
steps:
Remove obviously backported stuff from first steps.
Port forward the limitation of the exception backtrace size from step5
to later steps, so that REGRESS=1 does not crash stepA tests.
Fix the detection of special forms (strings were accepted as well as
symbols).
Let try* benefit from TCO.
Readability
* Use implicit parameter transmission ($(_list?) instead of $(call
_list?,$1),
first/lastword instead of word 1/words,
$1 instead of $(1).
* Use an undefined $(rem) macro and some automatic stripping (if,
foreach) to indent code with less calls to `strip` functions.
* Name the Make macro implementing a MAL core function exactly like the
function (modulo the encoding above) and simplify core_ns accordingly.
* Replace empty results representing `nil` with explicit MAL values.
* Implement large conditionals with a computed variable name, as already
done in printer.mk. For QUASIQUOTE and EVAL, this reduces a lot the
diff between steps.
* Represent the reader state as an explicit global variable instead of
passing the same name as argument again and again.
* Merge read-atom into read-form so that the switch on first character
is more visible.
Encapsulation
* Hide most representations into types.mk.
* Implement the type as a suffix in order to avoid a conditional in
_obj_type.
* Implement _error with throw.
* Create distinct types for keywords and macros.
* Move most metadata and atom stuff from core.mk to types.mk.
* Move parameter association from env to types because it hides more
about the representation of functions.
Representation
* Encode Make special characters in all strings/keywords/symbols, so
they can be used directly as spaced words and/or variable names for
map keys. (The encoding adding separating characters is kept for
read-string and seq).
* Change representation of numbers/strings/keywords/symbols, reducing
the number of Make variables.
Various
* Allow keyword argument for keyword core function.
* Shorten time-mes,slurp,readline...
* Remove obsolete stuff:
* `get` and `contains?` for vectors
* `count` for hash-maps
* `_join` from util.mk.
* `type` from core.mk.
* Add a function listing env_keys for DEBUG-EVAL.
* Fix some includes.
This improves readability because the return value was only a trick to
shorten `def!` and `defmacro!` and was ignored everywhere else.
As a side effect, this probably improves efficiency, as `let*` is the
most frequent caller.
Remove unneeded intermediate executable files.
Remove Cargo.lock from version control system.
Update dependency versions.
Update Dockerfile (converge to update-some-dockerfiles branch).
Apply changes suggested by rustfmt and clippy, or enforced by rustc.
Remove several unneeded clone().
Merge eval and eval-ast, remove quasiquoteexpand and macroexpand.
Report more errors during startup.
The package-lock.json file is intended to be checked in to source
control in order to make builds reproducible; without
a package-lock.json file `npm install` becomes non-deterministic.
See e.g.
https://docs.npmjs.com/cli/v8/configuring-npm/package-lock-json:
> package-lock.json is automatically generated for any operations where
> npm modifies either the node_modules tree, or package.json. It describes
> the exact tree that was generated, such that subsequent installs are
> able to generate identical trees, regardless of intermediate dependency
> updates.
>
> This file is intended to be committed into source repositories, and
> serves various purposes:
The update from ubuntu:vivid to ubuntu:20.04 update the version of sbcl
from 1.2.4.debian to 2.0.1.debian. This resulted in the cl-launch based
build process no longer working: dependencies were not resolved (but
running it several times would eventually resolve them. So use an sbcl
build command directly when building for sbcl.
Note: updating the image to ubuntu:24.04 upgrades the version of sbcl to
2.2.9.debian. Something about that version breaks how we do hash-maps.
They become temperamental: hash-map creation often results in a nil
object returned and doing (get hm key) usually results in nil returned
even if the key shows as being present.
Various trivial changes reducing the diff to #450.
Dockerfile: npm already depends on nodejs
Core.elm: change profile of deepEquals instead of uncurrying before
each call.
It was necessary to rename some ambiguous variables. Some more names
could probably be changed in order to reduce the diff with #450 (my
names were choosen in order to reduce the diff with master...)
Peek ideas from #450:
- sort imports
- skip a line between '->' or before 'else'
- no indentation after 'in'
- fix indentation when it was only intended to reduce diff
- remove some unneeded parenthesis
and
- if .. return True else False -> ...
Most changes are variable renamings because elm does not allow masking
a visible name anymore.
Deal with changes in the standard library, especially in the Parser
interface.
Source files must now start with a capital letter.
Dockerfile: remove unneeded dependencies, install nodejs from debs.
Remove the redundant Maybe from the return value of readstring.
Stop embedding the colon in keyword represenation.
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.
The modified implementations have been tested on Debian bullseye.
* prefer later Ubuntu image, hopefully reducing the image count
* for Ubuntu versions, prefer numerical versions to unsorted codenames
* prefer packaged build systems to local rebuilds
* prefer the current default version of each build system
* delegate resolution of indirect dependencies to apt
* xslt: remove intermediate run script. The initial motivation is to
provide an explicit path to the python3 interpreter, as the
versioned executable is not always in PATH.
* Add DEBIAN_FRONTEND=noninteractive to some Dockerfiles. This is to
workaround tzdata which prompts interactively by default.
* Debian/Ubuntu do not ship a python->python2 link by default.
* With the improved logo implementation in another branch, there is no
need anymore to tweat the garbage collector settings.
* logo: use upstream brandy compiler (instead of building).
* guile: adjust deb-src mechanism to build ucblogo and workaround doc
build bug.
c.2:
By updating to 24.04 we get around an error with declarations after
labels which is allowed in more recent compiler versions.
make:
With older make, the newer make code results in this error:
../make/readline.mk:13: *** unterminated call to function 'eval': missing ')'. Stop.
Newer versions of make work fine.
perl6:
With older rakudo, this error occurs:
user> (let* (DEBUG-EVAL false) (- 3 1))
Cannot resolve caller Numeric(types::MalFalse: ); none of these signatures match:
ocaml:
Fixes build error that happens with older versions of ocaml:
ocamlopt -a types.ml reader.ml printer.ml env.ml core.ml -o mal_lib.cmxa
File "env.ml", line 15, characters 8-21:
Error: Unbound value Data.find_opt
objpascal:
With older compiler, the following error occurs:
user> (apply str (seq "this is a test"))
*** Error in `../objpascal/stepA_mal': corrupted size vs. prev_size: 0x000000000246c360 ***
See issue #587.
* Merge eval-ast and eval into a single conditional.
* Expand macros during the apply phase, removing lots of duplicate
tests, and increasing the overall consistency by allowing the macro
to be computed instead of referenced by name (`((defmacro! cond
(...)))` is currently illegal for example).
* Print "EVAL: $ast" at the top of EVAL if DEBUG-EVAL exists in the
MAL environment.
* Remove macroexpand and quasiquoteexpand special forms.
* Use pattern-matching style in process/step*.txt.
Unresolved issues:
c.2: unable to reproduce with gcc 11.12.0.
elm: the directory is unchanged.
groovy: sometimes fail, but not on each rebuild.
nasm: fails some new soft tests, but the issue is unreproducible when
running the interpreter manually.
objpascal: unreproducible with fpc 3.2.2.
ocaml: unreproducible with 4.11.1.
perl6: unreproducible with rakudo 2021.09.
Unrelated changes:
Reduce diff betweens steps.
Prevent defmacro! from mutating functions: c forth logo miniMAL vb.
dart: fix recent errors and warnings
ocaml: remove metadata from symbols.
Improve the logo implementation.
Encapsulate all representation in types.lg and env.lg, unwrap numbers.
Replace some manual iterations with logo control structures.
Reduce the diff between steps.
Use native iteration in env_get and env_map
Rewrite the reader with less temporary strings.
Reduce the number of temporary lists (for example, reverse iteration
with butlast requires O(n^2) allocations).
It seems possible to remove a few exceptions: GC settings
(Dockerfile), NO_SELF_HOSTING (IMPLS.yml) and step5_EXCLUDES
(Makefile.impls) .
- Update to ubuntu 24.04 Dockerfile and add labels.
- update to working version of ffi-napi
- Remove from miniMAL-core.json the things that overlap with the builtin
core functionality that miniMAL now provides in 1.2.2.
- Update ARGS variable to argv to align with how 1.2.2 now does command
line parameters.
vivid packages are no longer available.
There are still implementations that use vivid because updating to
xenial was not sufficient to get them working again.
Most of the time, the WASI fd_read call returns the whole line including
the newline. Other times, it returns everything except the newline. So
before stompiing the newline, check for that condition. This fixes the
WASI based wasm implementations (wasmtime, wasmer, lucet).
The stack size on systems with higher ulimits (Github Actions) allows
this to complete and thus fail the test. Try with larger loop size to
try and trigger the problem even on those systems.
I added the exclusion as a hack to work around classpath
issues after importing the project into Eclipse, but this
isn't the right thing to do.
It prevents compilation on JDKs other than Graal, which was
not my intent.
GraalVM native image compilation wasn't working due to
some missing @TruffleBoundary annotations, and calls
from partially evaluated code into methods that are
black-listed for runtime compilation.
With these changes, a GraalVM native image should be
producable from every Mal step.
An uncaught exception in the self-hosting implementation causes the
interpreter to display the EVALed ast for each EVAL level until the
exception, something similare to a stack trace. This does not cost
much and may help a lot debugging the self-hosting step.
On the other hand, remove try* from step0 where it serves no useful
purpose.
Because of indentation level, this diff is better viewed with the git
-b command line option.
It should pass on existing implementations because it is a
prerequisite for an existing test, but small independent tests are
easyer to debug on new implementations.
Split user functions and macros, merge user functions and core functions.
Add a flag triggering debugging info in EVAL.
Reserve mutable environments for REPL and let*.
Move env type declaration from Types to Env.
Check let* arguments only once.
Share more code between map constructions and key type checks.
Stop copying metadata when evaluating collections.
The strict variant of Data.Map.Strict is recommended for general use.
simplify printer.
The grammar is not fully equivalent to the one in the process, but it
passes all tests.
I suggest that it becomes a formal/testable reference (are tabs
allowed as spaces? is "a~" valid? is "' a" valid?...).
As it is formuled here, it can directly be translated either to
another language with high-level parsers, or to a low-level language
as each production only switches after a look at the next input
character.
Another suggestion to simplify step1 is to make '{' a reader macro,
parsing "{a1 a2..}" into (hash-map a1 a2..).
The step1 tests should then accept both "(hash-map ..)" and "{a1..}",
but the process should in my opinion suggest the former as it moves
the complexity related to maps (language-dependent constructor,
argument count and type checking, reporting of such errors) form
reader.qx/step1 to core.qx/hash-map, where it has to be done later
anyway.
Turns out I was missing the @ExplodeLoop annotation on the
execute methods of VectorNode and MapNode. These annotations
trigger loop unrolling. I had thought they were simply for
performance, but in fact they are necessary to ensure that
the correct specializations get selected for each of the
child nodes. Without them, we get compiler bailouts for
functions that include vector and map literals.