jackhill/mal.git
5 years agobbc-basic: Minimal step 1.
Ben Harris [Sun, 31 Mar 2019 21:44:13 +0000 (22:44 +0100)]
bbc-basic: Minimal step 1.

5 years agobbc-basic: convert reader to follow Hints.md.
Ben Harris [Sun, 31 Mar 2019 16:12:12 +0000 (17:12 +0100)]
bbc-basic: convert reader to follow Hints.md.

5 years agobbc-basic: Rework tokenizer.
Ben Harris [Sun, 31 Mar 2019 10:38:08 +0000 (11:38 +0100)]
bbc-basic: Rework tokenizer.

Now all tokens are emitted after reading the next character, rather
than emitting some as soon as their last character is read.  This
simplifies the token-emission code at the expense of adding a state to
the DFA.

5 years agobbc-basic: Remove PRINT statements from tokenizer.
Ben Harris [Sun, 31 Mar 2019 09:44:25 +0000 (10:44 +0100)]
bbc-basic: Remove PRINT statements from tokenizer.

5 years agobbc-basic: Tokenizer based on a DFA.
Ben Harris [Sun, 31 Mar 2019 08:19:03 +0000 (09:19 +0100)]
bbc-basic: Tokenizer based on a DFA.

DATA statements are pretty much perfect for this job.

5 years agobbc-basic: Working step 0.
Ben Harris [Sat, 30 Mar 2019 10:35:27 +0000 (10:35 +0000)]
bbc-basic: Working step 0.

I'm far from sure the I/O is actually reliable, but the tests pass.

5 years agoMinimal structure for BBC BASIC implementation.
Ben Harris [Sat, 30 Mar 2019 09:31:09 +0000 (09:31 +0000)]
Minimal structure for BBC BASIC implementation.

5 years agoscheme: fix unterminated string handling for chibi
Vasilij Schneidermann [Fri, 17 May 2019 20:46:59 +0000 (22:46 +0200)]
scheme: fix unterminated string handling for chibi

5 years agoscheme: fix unterminated string handling
Vasilij Schneidermann [Fri, 17 May 2019 06:44:42 +0000 (08:44 +0200)]
scheme: fix unterminated string handling

5 years agoMerge pull request #381 from bjh21/bjh21-unterminated-string-fixes
Joel Martin [Fri, 17 May 2019 04:14:38 +0000 (23:14 -0500)]
Merge pull request #381 from bjh21/bjh21-unterminated-string-fixes

Unterminated string fixes: gnu-smalltalk, go, js, lua, objpascal, php, powershell, racket, rust, ts

5 years agopicolisp: fix unterminated string handling
Vasilij Schneidermann [Thu, 16 May 2019 21:45:23 +0000 (23:45 +0200)]
picolisp: fix unterminated string handling

5 years agoobjpascal, powershell, racket: Detect more unterminated strings.
Ben Harris [Thu, 16 May 2019 19:28:09 +0000 (20:28 +0100)]
objpascal, powershell, racket: Detect more unterminated strings.

This is achieved by tightening the regexp used to detect valid strings.

5 years agognu-smalltalk, go, js, lua, php, rust, ts: Detect more unterminated strings.
Ben Harris [Thu, 16 May 2019 19:16:36 +0000 (20:16 +0100)]
gnu-smalltalk, go, js, lua, php, rust, ts: Detect more unterminated strings.

Rather than treating anything beginning and ending with '"' as a valid
string, we now use a regexp to detect a valid string and treat any other
token starting with '"' as an error.

5 years agoMerge pull request #379 from bjh21/bjh21-unterminated-string-fixes
Joel Martin [Wed, 15 May 2019 22:33:48 +0000 (15:33 -0700)]
Merge pull request #379 from bjh21/bjh21-unterminated-string-fixes

cs, crystal, es6: Detect more unterminated strings.

5 years agocs, crystal, es6: Detect more unterminated strings.
Ben Harris [Wed, 15 May 2019 21:41:06 +0000 (22:41 +0100)]
cs, crystal, es6: Detect more unterminated strings.

Specifically, correctly handle invalid strings that nonetheless end with
a '"' character, by using the full string-matching regexp to check that
a string token is valid.

5 years agops: properly ignore multiple comments in a row.
Joel Martin [Wed, 15 May 2019 17:11:21 +0000 (12:11 -0500)]
ps: properly ignore multiple comments in a row.

5 years agoMerge pull request #378 from asarhaddon/test-macro-not-changing-function
Joel Martin [Wed, 15 May 2019 15:17:59 +0000 (08:17 -0700)]
Merge pull request #378 from asarhaddon/test-macro-not-changing-function

Test that defining a macro does not mutate an existing function.

5 years agoMove test that macro do not mutate functions as optional in stepA
Nicolas Boulenguez [Wed, 15 May 2019 04:07:45 +0000 (06:07 +0200)]
Move test that macro do not mutate functions as optional in stepA

5 years agotest macro/functions: ignore results of preliminary definitions
Nicolas Boulenguez [Wed, 15 May 2019 03:10:11 +0000 (05:10 +0200)]
test macro/functions: ignore results of preliminary definitions

5 years agoMerge pull request #377 from asarhaddon/fix-runtests-pre-eval
Joel Martin [Wed, 15 May 2019 01:56:37 +0000 (18:56 -0700)]
Merge pull request #377 from asarhaddon/fix-runtests-pre-eval

runtest: fix pre-eval option

5 years agoMerge pull request #376 from bjh21/bjh21-withmeta-empty
Joel Martin [Wed, 15 May 2019 00:25:35 +0000 (17:25 -0700)]
Merge pull request #376 from bjh21/bjh21-withmeta-empty

step A: Test that metadata doesn't break empty collections.

5 years agoMerge pull request #375 from bjh21/bjh21-stepA-optional
Joel Martin [Tue, 14 May 2019 23:01:35 +0000 (16:01 -0700)]
Merge pull request #375 from bjh21/bjh21-stepA-optional

Document the requirements for optional step A functions

5 years agostep A: Test that metadata doesn't break empty collections.
Ben Harris [Tue, 14 May 2019 22:28:13 +0000 (23:28 +0100)]
step A: Test that metadata doesn't break empty collections.

In the BBC BASIC implementation, the empty list, vector, and hash-mapp
are distinguished values and detected by their address.  Adding metadata
to them makes a copy, and then they don't work properly any more.

5 years agoguide, step A: Note that stub functions are replaced with real ones.
Ben Harris [Tue, 14 May 2019 21:32:55 +0000 (22:32 +0100)]
guide, step A: Note that stub functions are replaced with real ones.

5 years agostep A: Add a mandatory test that 'string?' etc are defined.
Ben Harris [Tue, 14 May 2019 21:22:39 +0000 (22:22 +0100)]
step A: Add a mandatory test that 'string?' etc are defined.

Self-hosting currently requires that these functions be defined so
that the mal implementation can pass them through.  This test
minimally ensures that.

5 years agoguide, step A: Document that 'string?' etc need to be defined.
Ben Harris [Tue, 14 May 2019 21:19:34 +0000 (22:19 +0100)]
guide, step A: Document that 'string?' etc need to be defined.

The functions 'time-ms', 'string?', 'number?', 'seq', an 'conj' don't
need to work for self-hosting, but they do need to be defined, since
mal/core.mal unconditionally references them when the interpreter
starts up.

5 years agoTest that defining a macro does not mutate an existing function.
Nicolas Boulenguez [Tue, 14 May 2019 16:39:42 +0000 (18:39 +0200)]
Test that defining a macro does not mutate an existing function.

5 years agoruntest: fix pre-eval option
Nicolas Boulenguez [Tue, 14 May 2019 16:12:59 +0000 (18:12 +0200)]
runtest: fix pre-eval option

5 years agoMerge pull request #372 from bjh21/bjh21-empty-hashmap
Joel Martin [Mon, 13 May 2019 22:31:45 +0000 (15:31 -0700)]
Merge pull request #372 from bjh21/bjh21-empty-hashmap

step1: Test that an empty hashmap can pass through read and print.

5 years agostep1: More systematic testing of empty collections.
Ben Harris [Mon, 13 May 2019 20:53:43 +0000 (21:53 +0100)]
step1: More systematic testing of empty collections.

Now we test empty lists, vectors, and hash-maps, all with and without a
space between the opening and closing bracket.

5 years agowasm: fix platform_wasi preopen search.
Joel Martin [Sun, 12 May 2019 04:04:15 +0000 (23:04 -0500)]
wasm: fix platform_wasi preopen search.

This better supports both wasmtime and wasmer. One key issue is that
we need to handle string endings differently between the two projects.

5 years agohaskell: fix parsing empty literal sequences.
Joel Martin [Mon, 13 May 2019 18:39:49 +0000 (13:39 -0500)]
haskell: fix parsing empty literal sequences.

Specifically the problem is that parsing sequence literals breaks if
there are only empty spaces between the opening and closing character.

This is to address issues found in: https://github.com/kanaka/mal/pull/372

5 years agoMerge pull request #374 from sgtatham/vala-fixes
Joel Martin [Mon, 13 May 2019 17:26:37 +0000 (10:26 -0700)]
Merge pull request #374 from sgtatham/vala-fixes

Vala fixes

5 years agomake, swift3: fix parsing empty literal sequences.
Joel Martin [Mon, 13 May 2019 16:57:15 +0000 (11:57 -0500)]
make, swift3: fix parsing empty literal sequences.

Specifically the problem is that parsing sequence literals breaks if
there are only empty spaces between the opening and closing character.

This is to address issues found in: https://github.com/kanaka/mal/pull/372

5 years agovala: implement a garbage collector.
Simon Tatham [Sun, 12 May 2019 09:05:34 +0000 (10:05 +0100)]
vala: implement a garbage collector.

This fixes a lot of memory leakage due to me having relied on the Vala
reference-counting system to do my memory management.

The most obvious bad result of that design decision was the memory
leak from Mal.Nil pointing to itself as metadata. But fixing that
didn't solve the whole problem, because other kinds of reference cycle
are common.

In particular, the idiom `(def! FUNC (fn* (ARGS) BODY))`, for defining
a function in the most obvious way, would create a cycle of two
objects: from the outer environment in which FUNC is defined, to the
function object for FUNC itself, back to that same environment because
it was captured by FUNC.

And _either_ of those objects could end up being the only element of
the cycle referred to from the rest of the system: it could be the
environment, if nothing ever uses that function definition, or it
could be the function, if that function object is looked up and
returned from an outer function that was the last user of the
environment. So you can't break the cycle in the way that reference
counting systems would like you to, by making a well-chosen one of the
links weak: there's no universally right choice for which one it needs
to be.

So I've fixed it properly by writing a simple garbage collector. In
Vala's ref-counted environment, that works by being the only thing
allowed to hold an _owning_ reference to any derivative of GC.Object.
All the normal kinds of link between objects are now weak references;
each object provides a gc_traverse method which lists all the things
it links to; and when the garbage collector runs, it unlinks any
unwanted objects from its big linked list of all of them, causing the
one owned reference to each one to disappear.

Now the perf3 test can run without its memory usage gradually
increasing.

5 years agovala: expose length/get/set methods for Mal.Vector.
Simon Tatham [Sun, 12 May 2019 09:27:30 +0000 (10:27 +0100)]
vala: expose length/get/set methods for Mal.Vector.

Partly, this makes the external API less cumbersome. Mostly, it hides
the details of the class's implementation, which I'm about to want to
change.

5 years agovala: make Env's internal storage private.
Simon Tatham [Sun, 12 May 2019 08:17:46 +0000 (09:17 +0100)]
vala: make Env's internal storage private.

This enforces that nothing outside the Env class refers directly to it, which will allow me to

5 years agovala: remove the as_glib_list helper function.
Simon Tatham [Sun, 12 May 2019 08:17:34 +0000 (09:17 +0100)]
vala: remove the as_glib_list helper function.

It turned out I only ever called in one place, and I'm about to change
that call site to do things differently anyway.

5 years agovala: allow metadata pointer to be null.
Simon Tatham [Sat, 11 May 2019 08:01:30 +0000 (09:01 +0100)]
vala: allow metadata pointer to be null.

My base class Mal.ValWithMetadata defaulted to filling in an object's
metadata pointer with an instance of Mal.Nil. Since Mal.Nil objects
are not all commoned together in this implementation, it seems like a
lot of pointless effort to create all those extra Nil objects, when
most of them will never be consulted at all. So now we initialise the
metadata pointer to null rather than an instance of Nil, and
manufacture a Nil as the return value only when the core 'meta'
function is asked to return the metadata from such an object.

(Also, Mal.Nil itself is a subclass of ValWithMetadata, and to avoid
infinite recursion of constructors, I linked it to itself as its own
metadata, creating a trivial reference cycle. That created quite a big
memory leak all by itself! But since I'm about to introduce a garbage
collector which will solve the leakage problem much more generally,
that's no longer an important reason to make this change.)

5 years agovala: fix handling of unterminated strings.
Simon Tatham [Fri, 10 May 2019 22:45:37 +0000 (23:45 +0100)]
vala: fix handling of unterminated strings.

This fixes the two test cases in Ben Harris's unmerged PR #359.

5 years agovala Makefile: add a VFLAGS variable.
Simon Tatham [Mon, 13 May 2019 08:14:52 +0000 (09:14 +0100)]
vala Makefile: add a VFLAGS variable.

This makes it easy to recompile with debug flags.

5 years agoMerge pull request #370 from asarhaddon/hide-gensym-counter
Joel Martin [Mon, 13 May 2019 14:33:35 +0000 (07:33 -0700)]
Merge pull request #370 from asarhaddon/hide-gensym-counter

gensym: hide the counter in an environment, define inc in stepA.

5 years agovala Makefile: define an empty .SUFFIXES.
Simon Tatham [Sun, 12 May 2019 09:05:23 +0000 (10:05 +0100)]
vala Makefile: define an empty .SUFFIXES.

This fixes an annoying make behaviour where, if the Vala compiler
leaves around a file called foo.vala.c (as it does in some forms of
compile failure), make will automatically try to rebuild foo.vala from
it. This fails, because a single valac-output source file will
basically never compile using make's default cc command – and it's
lucky it does fail, because it would overwrite a real Vala source file
if it didn't!

Defining .SUFFIXES to the empty string suppresses all the built-in
things GNU make thinks it knows about how to compile things, and
forces it to rely only on the rules actually written down in this
Makefile.

5 years agostep1: Test that an empty hashmap can pass through read and print.
Ben Harris [Sun, 12 May 2019 12:58:53 +0000 (13:58 +0100)]
step1: Test that an empty hashmap can pass through read and print.

My BBC BASIC implementation currently fails this.

5 years agogensym: changes forgotten in last commit
Nicolas Boulenguez [Sat, 11 May 2019 15:43:17 +0000 (17:43 +0200)]
gensym: changes forgotten in last commit

5 years agoFix typos detected by automated tests.
Nicolas Boulenguez [Sat, 11 May 2019 15:39:46 +0000 (17:39 +0200)]
Fix typos detected by automated tests.

5 years agogensym: hide the counter in an environment, define inc in stepA.
Nicolas Boulenguez [Sat, 11 May 2019 14:25:20 +0000 (16:25 +0200)]
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

5 years agod: support ldc2 and dmd modes from top-level.
Joel Martin [Fri, 10 May 2019 19:05:53 +0000 (14:05 -0500)]
d: support ldc2 and dmd modes from top-level.

Symlink dmd to /usr/bin in the dockerfile so that no PATH modification
is necessary.

Also, add a runtime modes count to the README.

5 years agovala: more standard form for vala/Dockerfile
Joel Martin [Fri, 10 May 2019 19:04:08 +0000 (14:04 -0500)]
vala: more standard form for vala/Dockerfile

For more efficient layer sharing with other implementations.

5 years agoMerge pull request #368 from sgtatham/vala
Joel Martin [Fri, 10 May 2019 18:54:33 +0000 (11:54 -0700)]
Merge pull request #368 from sgtatham/vala

Vala

5 years agoUpdate counters and .travis.yml.
Simon Tatham [Fri, 10 May 2019 18:42:25 +0000 (19:42 +0100)]
Update counters and .travis.yml.

5 years agoMerge pull request #367 from kuettler/master
Joel Martin [Fri, 10 May 2019 18:32:06 +0000 (11:32 -0700)]
Merge pull request #367 from kuettler/master

D: Get the code to compile with all three current d compilers

5 years agoAdd build rules for dmd and ldc in addition to gdc. Update Dockerfile to install...
Ulrich Küttler [Fri, 10 May 2019 13:59:36 +0000 (15:59 +0200)]
Add build rules for dmd and ldc in addition to gdc. Update Dockerfile to install all three compilers.

5 years agoAdd an implementation written in Vala.
Simon Tatham [Fri, 10 May 2019 08:34:20 +0000 (09:34 +0100)]
Add an implementation written in Vala.

I needed to learn Vala in order to work on an existing program written
in it, and since Ben Harris had been enthusing about mal to me
recently, I thought this would be a good way to learn the language.

In other words, this is my first Vala project, so I can't promise it's
perfectly idiomatic by the standards of experienced Vala programmers!

Also, the style isn't all that consistent. For example, sometimes I
implement a function for every value type by adding a method to the
Mal.Val base class, and sometimes instead I do it by having a function
(e.g. pr_str) dynamically test all the possible subtypes in a chain of
else-ifs.

Those decisions were partly because of the source file structure
required by this project (pr_str is supposed to live in its own file);
partly because for my own learning goals I wanted to try both
strategies and find out how easy they both were; and mostly just
because of indecision and bad planning.

5 years agoguide.md: fix a few trivial typos.
Simon Tatham [Sat, 4 May 2019 09:08:32 +0000 (10:08 +0100)]
guide.md: fix a few trivial typos.

5 years agoD: Get the code to compile with all three current d compilers
Ulrich Küttler [Thu, 9 May 2019 20:52:23 +0000 (22:52 +0200)]
D: Get the code to compile with all three current d compilers

- Work around a D bug to get exception handling going
- Fix imports
- Modernize pointer downcasts

5 years agoMerge pull request #366 from bjh21/bjh21-unterminated-string-fixes
Joel Martin [Wed, 8 May 2019 23:28:57 +0000 (16:28 -0700)]
Merge pull request #366 from bjh21/bjh21-unterminated-string-fixes

Some fixes for unterminated strings

5 years agobash, ruby: Fix reading of unterminated strings that happen to end with '"'.
Ben Harris [Wed, 8 May 2019 21:45:08 +0000 (22:45 +0100)]
bash, ruby: Fix reading of unterminated strings that happen to end with '"'.

In both cases by re-using the string-matching regexp fragment from the
tokenizer.

5 years agoawk: Fix reading of unterminated strings that happen to end with '"'.
Ben Harris [Wed, 8 May 2019 21:17:43 +0000 (22:17 +0100)]
awk: Fix reading of unterminated strings that happen to end with '"'.

5 years agoperl, python, tcl: Correctly detect more unterminated strings.
Ben Harris [Wed, 8 May 2019 21:00:55 +0000 (22:00 +0100)]
perl, python, tcl: Correctly detect more unterminated strings.

In all cases, this is just by using the equivalent of the full
string-matching regexp from 'tokenize'.

While I'm in the area, also remove an unnecessary ".*" from the regexp
to match a leading quotation mark in Perl and Tcl.

5 years agonasm: fix empty list handling
Joel Martin [Wed, 8 May 2019 04:44:22 +0000 (23:44 -0500)]
nasm: fix empty list handling

5 years agoMerge pull request #365 from asarhaddon/cpp-ada.2-conformance
Joel Martin [Wed, 8 May 2019 17:15:55 +0000 (10:15 -0700)]
Merge pull request #365 from asarhaddon/cpp-ada.2-conformance

Cpp ada.2 conformance

5 years agoMerge pull request #358 from bjh21/bjh21-extra-tests
Joel Martin [Wed, 8 May 2019 15:16:26 +0000 (08:16 -0700)]
Merge pull request #358 from bjh21/bjh21-extra-tests

A couple of extra tests

5 years agoada.2 switch back `do` from built-in function to special form
Nicolas Boulenguez [Wed, 8 May 2019 01:07:45 +0000 (03:07 +0200)]
ada.2 switch back `do` from built-in function to special form

The benefit of this devianceto the process is dubious.

5 years agoC++ convert map from native to built-in
Nicolas Boulenguez [Wed, 8 May 2019 01:06:45 +0000 (03:06 +0200)]
C++ convert map from native to built-in

5 years agostep 7 test: Add test of 'concat' on a single vector.
Ben Harris [Mon, 6 May 2019 14:58:42 +0000 (15:58 +0100)]
step 7 test: Add test of 'concat' on a single vector.

I thought I'd accidentally made it just return that vector, but it
turned out I hadn't.  Still, it seems like a plausible mistake to
make.

5 years agostep 8 test: Check a corner case of cons/rest on vectors that I got wrong.
Ben Harris [Mon, 6 May 2019 11:28:53 +0000 (12:28 +0100)]
step 8 test: Check a corner case of cons/rest on vectors that I got wrong.

In the BBC BASIC implementation, lists and vectors are essentially the
same, and are only distinguished by a flag on the head node.  This makes
it cheap to convert between lists and vectors, but it does require a
little care to ensure that a vector doesn't escape where it shouldn't.
The new test checks for a case where I'd got this wrong:

(rest (cons 10 [11 12]))

Here the 'cons' returns a list, but the tail of the list is just the
original vector (complete with vector flag), so a naïve implementation
of 'rest' can end up returning that vector instead of an equivalent
list.  The test proves that it doesn't.

5 years agoMerge pull request #363 from bjh21/bjh21-concat-ocaml
Joel Martin [Tue, 7 May 2019 22:46:25 +0000 (15:46 -0700)]
Merge pull request #363 from bjh21/bjh21-concat-ocaml

ocaml: Fix result of (concat [1 2]), so it returns a list not a vector.

5 years agocrystal,java: fix empty list handling.
Joel Martin [Tue, 7 May 2019 22:44:16 +0000 (17:44 -0500)]
crystal,java: fix empty list handling.

5 years agoMerge pull request #362 from bjh21/bjh21-concat-ps
Joel Martin [Tue, 7 May 2019 22:03:52 +0000 (15:03 -0700)]
Merge pull request #362 from bjh21/bjh21-concat-ps

ps: Fix result of (concat [1 2]), so it returns a list not a vector.

5 years agoocaml: Fix result of (concat [1 2]), so it returns a list not a vector.
Ben Harris [Tue, 7 May 2019 21:59:26 +0000 (22:59 +0100)]
ocaml: Fix result of (concat [1 2]), so it returns a list not a vector.

5 years agoswift4: exit on EOF/Ctrl-D.
Joel Martin [Wed, 8 May 2019 04:53:40 +0000 (23:53 -0500)]
swift4: exit on EOF/Ctrl-D.

5 years agorpython,rust,swift4,ts: fix empty list handling.
Joel Martin [Wed, 8 May 2019 04:38:07 +0000 (23:38 -0500)]
rpython,rust,swift4,ts: fix empty list handling.

In these implementations there is no empty list check before
macroexpansion and so empty lists from step8 onwards produce a crash
or other misbehavior.

Also, add a test to step8 to test empty list again (first time it's
tested is in step2).

5 years agops: Fix result of (concat [1 2]), so it returns a list not a vector.
Ben Harris [Tue, 7 May 2019 21:04:28 +0000 (22:04 +0100)]
ps: Fix result of (concat [1 2]), so it returns a list not a vector.

5 years agoMerge pull request #360 from asarhaddon/convert-divergent-native-to-builtin
Joel Martin [Tue, 7 May 2019 16:12:23 +0000 (09:12 -0700)]
Merge pull request #360 from asarhaddon/convert-divergent-native-to-builtin

Convert divergent native functions to built-in functions.

5 years agoLivescript Convert `not` from native to built-in.
Nicolas Boulenguez [Tue, 7 May 2019 09:31:47 +0000 (11:31 +0200)]
Livescript Convert `not` from native to built-in.

5 years agoGuile Convert `not` from native to built-in.
Nicolas Boulenguez [Tue, 7 May 2019 09:22:26 +0000 (11:22 +0200)]
Guile Convert `not` from native to built-in.

5 years agoForth Convert `not` from native to built-in.
Nicolas Boulenguez [Tue, 7 May 2019 09:12:59 +0000 (11:12 +0200)]
Forth Convert `not` from native to built-in.

5 years agoC++ Convert `< > >= list` from native to built-in.
Nicolas Boulenguez [Tue, 7 May 2019 08:56:11 +0000 (10:56 +0200)]
C++ Convert `< > >= list` from native to built-in.

Converting `map` is less trivial.

5 years agoMerge pull request #357 from bjh21/bjh21-minor-fixes
Joel Martin [Mon, 6 May 2019 14:38:27 +0000 (07:38 -0700)]
Merge pull request #357 from bjh21/bjh21-minor-fixes

Another round of minor doc/test fixes

5 years agostep 7 test: Correct a heading to match contents.
Ben Harris [Mon, 6 May 2019 11:25:52 +0000 (12:25 +0100)]
step 7 test: Correct a heading to match contents.

'first' and 'rest' applied to vectors are now tested in step 8, not step 7.

5 years agoguide.md: Move description of 'sequential?' to a more logical place.
Ben Harris [Sun, 5 May 2019 22:57:12 +0000 (23:57 +0100)]
guide.md: Move description of 'sequential?' to a more logical place.

It's still a deferrable part of step 9, but now it's listed with the
other vector-related functions rather than after the hash-map-related
ones.

5 years agostep9: Don't use vectors in a non-deferrable test.
Ben Harris [Wed, 1 May 2019 11:16:11 +0000 (12:16 +0100)]
step9: Don't use vectors in a non-deferrable test.

According to the guide, vectors are deferrable until step A, so use
(nth () 1) in place of (nth [] 1) as a form that will generate an error.

5 years agostep9: Make test of throwing a hash-map deferrable.
Ben Harris [Wed, 1 May 2019 11:15:14 +0000 (12:15 +0100)]
step9: Make test of throwing a hash-map deferrable.

According to the guide, hash-maps are deferrable until step A.

5 years agoMerge pull request #354 from asarhaddon/simplify-core-mal
Joel Martin [Sun, 5 May 2019 22:37:11 +0000 (15:37 -0700)]
Merge pull request #354 from asarhaddon/simplify-core-mal

Trivial simplifications in core.mal.

5 years agoMerge pull request #356 from asarhaddon/swift4-duplicate-lines
Joel Martin [Sun, 5 May 2019 22:27:18 +0000 (15:27 -0700)]
Merge pull request #356 from asarhaddon/swift4-duplicate-lines

swift4: remove duplicate definition of load-file

5 years agoswift4: remove duplicate definition of load-file
Nicolas Boulenguez [Sun, 5 May 2019 18:39:37 +0000 (20:39 +0200)]
swift4: remove duplicate definition of load-file

5 years agoTrivial simplifications in core.mal.
Nicolas Boulenguez [Wed, 24 Apr 2019 18:12:53 +0000 (20:12 +0200)]
Trivial simplifications in core.mal.

Replace many (= (count xs) 0) with (empty? x).

Stop definining 'not', 'or' and 'cond' in core.mal, they are defined
in the process steps.

In 'some', avoid computing the same result twice.

Explain the final nil evaluation.

5 years agoMerge pull request #355 from asarhaddon/improve-ada.2
Joel Martin [Fri, 3 May 2019 14:48:33 +0000 (07:48 -0700)]
Merge pull request #355 from asarhaddon/improve-ada.2

Clarify and optimize ada.2.

5 years agoClarify and optimize ada.2.
Nicolas Boulenguez [Thu, 2 May 2019 19:19:34 +0000 (21:19 +0200)]
Clarify and optimize ada.2.

Makefile:
Drop OPT and -gnat2020, not used anymore.
Simplify file list now that each unit has a body.

README:
Remove obsolete items.

Global:
Restrict most pointers to a provable non-null value.

Types: merge intermediate Types.Mal into the Types package.  (the
intermediate package was created in order to prevent a circular
dependency, but is not needed anymore).
Most of the noise in the diff is caused by this change.
This allows to remove most Elaboration pragmas.
Declare most types abstract in the visible part,
enforcing the use of the constructor outside the declaring package.

Envs:
Replace the Get recursion with a more efficient loop.
Use MAL objects as key, string pointers do not change speed.
This delegates some checks from the step files.
Split the constructor and Set_Binds, so that an existing environment
can be reused during TCO.

Err:
Attempt to group the calls.
Avoid computing the message when the assertion holds.

Fns:
Declare and use the eval callback only here.
Separate function and macro interfaces.
Keep a reference to the provided parameter list instead of copying them.

Garbage_Collected:
Make explicit that Keep is not inherited.

Printer:
Remove obsolete inline indications and redundant Print_Function helper.

Maps:
Provide a cleaner interface copied from standard library.

Sequences: stop encapsulating the implementation because of the
performance hit.

Steps:
Move map and vector evaluations into separate functions for readability.
Replace return blocks with normal blocks (MAL values are not finalized
anymore).
Rename standard arrays instead of sequence_ptr when possible.
Remove some duplication and indentation from the apply phase.
Move the frequent special forms in front of the test cascade.
When an environment has been created in the same Eval, reuse it.

Strings:
Use the same garbage-collected storage model for all strings.
This seems faster than the default (mutable) string types.
Hide most of the implementation to avoid leaks.

Symbols: stop ensuring unique allocation of symbols. The reduced
garbage collection and comparison time was compensed by the
maintainance of a global hash.

5 years agoMerge pull request #353 from bjh21/bjh21-minor-fixes
Joel Martin [Sun, 21 Apr 2019 02:28:05 +0000 (21:28 -0500)]
Merge pull request #353 from bjh21/bjh21-minor-fixes

Minor doc/test fixes

5 years agoGuide: when introducing read_atom, don't mention complex types.
Ben Harris [Sat, 20 Apr 2019 18:00:08 +0000 (19:00 +0100)]
Guide: when introducing read_atom, don't mention complex types.

Vectors, hash-maps, and atoms wouldn't be read by read_atom anyway.
Atoms don't even have a read syntax.  While I'm there, also correct
which step keywords turn up in (step A, not step 9).

5 years agoStep 6: Make tests of '*ARGV*' deferrable.
Ben Harris [Sat, 20 Apr 2019 17:49:29 +0000 (18:49 +0100)]
Step 6: Make tests of '*ARGV*' deferrable.

The Guide says that '*ARGV*' is deferrable at step 6.

5 years agowasm: wax runtime. Use WASI preopen process.
Joel Martin [Fri, 19 Apr 2019 06:07:08 +0000 (01:07 -0500)]
wasm: wax runtime. Use WASI preopen process.

Add wasi-sdk to Dockerfile to be able to compile C code to wasm that
uses WASI API calls.

5 years agoREADME: add webassembly embeddings/runtimes.
Joel Martin [Wed, 17 Apr 2019 05:35:39 +0000 (00:35 -0500)]
README: add webassembly embeddings/runtimes.

5 years agowasm: Support/add wasmtime runtime. WASI platform.
Joel Martin [Tue, 16 Apr 2019 03:08:07 +0000 (22:08 -0500)]
wasm: Support/add wasmtime runtime. WASI platform.

5 years agowasm: use wam-1.0.8 which supports new binaryen.
Joel Martin [Tue, 16 Apr 2019 01:54:11 +0000 (20:54 -0500)]
wasm: use wam-1.0.8 which supports new binaryen.

New binaryen doesn't allow data section to contain multiple strings to
be concatenated together any more. So wamp-1.0.8 does the
concatenating for it.

5 years agowasm: direct platform, wam memory
Joel Martin [Mon, 15 Apr 2019 05:57:59 +0000 (00:57 -0500)]
wasm: direct platform, wam memory

- Rename platform_os.wam to platform_direct.wam and update the direct
  interface to use printline instead of fputs/stdout.
- Update to wamp 1.0.7 and new memory/memoryBase semantics: in
  platform_direct and platform_libc, import memory and memoryBase
  rather than relying on wamp to add it because wamp add direct memory
  and memoryBase defintions (not imports) if the program doesn't
  already define or import memory/memoryBase.
- Simplify entry point logic by moving it into the platform files.

5 years agoREADME: reorganize slightly.
Joel Martin [Sat, 13 Apr 2019 16:57:15 +0000 (11:57 -0500)]
README: reorganize slightly.

Move external implementations and other mal projects above the long
implementation details section. The implementation details are linked
to from the overview section so it's fine to have that lower on the
page.

5 years agoguide.md: In step 1, correctly state how long strings can be deferred.
Ben Harris [Wed, 10 Apr 2019 22:29:30 +0000 (23:29 +0100)]
guide.md: In step 1, correctly state how long strings can be deferred.