jackhill/mal.git
4 years agoAdd python.2 implementation
Gavin Lewis [Sun, 18 Aug 2019 17:05:48 +0000 (10:05 -0700)]
Add python.2 implementation

This commit adds a new Python 3 implementation of MAL. This
implementation passes all non-optional tests, with the exception
that the travis test script doesn't like the period in the
directory name. During development, this was called "py3" and
it passed Travis tests.

This implementation is different from the main python implementation.
First, it heavily uses type annotations making for a code style
more similar to Java. Second, it uses the Arpeggio parser library
to parse MAL syntax.

This commit also includes unit tests that show roughly the order
of things that were interactively tested and debugged during
development.

4 years agoMerge pull request #451 from seven1m/malcc-link
Joel Martin [Fri, 4 Oct 2019 16:06:55 +0000 (12:06 -0400)]
Merge pull request #451 from seven1m/malcc-link

Link to malcc on GitHub

4 years agoLink to malcc on GitHub
Tim Morgan [Fri, 4 Oct 2019 04:51:13 +0000 (23:51 -0500)]
Link to malcc on GitHub

4 years agoMerge pull request #448 from rofrol/rust-rustfmt
Joel Martin [Wed, 18 Sep 2019 17:42:25 +0000 (12:42 -0500)]
Merge pull request #448 from rofrol/rust-rustfmt

rust: rustfmt

4 years agoMerge pull request #449 from dubek/pike-impl
Joel Martin [Wed, 18 Sep 2019 15:09:32 +0000 (10:09 -0500)]
Merge pull request #449 from dubek/pike-impl

Pike implementation

4 years agotravis: Add pike to the test matrix
Dov Murik [Wed, 18 Sep 2019 05:55:53 +0000 (08:55 +0300)]
travis: Add pike to the test matrix

4 years agoREADME: add Pike implementation
Dov Murik [Wed, 18 Sep 2019 05:53:48 +0000 (08:53 +0300)]
README: add Pike implementation

4 years agoAdd Pike implementation
Dov Murik [Wed, 18 Sep 2019 05:49:33 +0000 (08:49 +0300)]
Add Pike implementation

4 years agoMerge pull request #447 from rofrol/rust-remove-readline.rs
Joel Martin [Tue, 17 Sep 2019 19:01:42 +0000 (14:01 -0500)]
Merge pull request #447 from rofrol/rust-remove-readline.rs

rust: remove readline.rs

4 years agorust: rustfmt
Roman Frołow [Tue, 17 Sep 2019 18:55:49 +0000 (20:55 +0200)]
rust: rustfmt

4 years agorust: remove readline.rs
Roman Frołow [Tue, 17 Sep 2019 18:31:15 +0000 (20:31 +0200)]
rust: remove readline.rs

4 years agoMerge pull request #444 from bjh21/bjh21-bare-newline
Joel Martin [Tue, 27 Aug 2019 14:36:27 +0000 (09:36 -0500)]
Merge pull request #444 from bjh21/bjh21-bare-newline

step 6: Test reading strings containing bare newlines.

4 years agotcl, yorick: fix read-string of raw newline.
Joel Martin [Tue, 27 Aug 2019 05:28:43 +0000 (00:28 -0500)]
tcl, yorick: fix read-string of raw newline.

4 years agoawk, bash: fix read-string of raw newline.
Joel Martin [Thu, 22 Aug 2019 02:44:42 +0000 (21:44 -0500)]
awk, bash: fix read-string of raw newline.

Also, cleanup up bash tokenizer a bit.

4 years agoMerge pull request #445 from bjh21/bjh21-bbc-basic
Joel Martin [Wed, 21 Aug 2019 21:47:39 +0000 (16:47 -0500)]
Merge pull request #445 from bjh21/bjh21-bbc-basic

bbc-basic: Permit bare newlines in strings.

4 years agobbc-basic: Permit bare newlines in strings.
Ben Harris [Wed, 21 Aug 2019 20:03:59 +0000 (21:03 +0100)]
bbc-basic: Permit bare newlines in strings.

The official regexp allows them.

4 years agostep 6: Test reading strings containing bare newlines.
Ben Harris [Wed, 21 Aug 2019 19:50:48 +0000 (20:50 +0100)]
step 6: Test reading strings containing bare newlines.

The official regexps permit bare newlines in strings, and the mal
implementation currently contains one.

4 years agoMerge pull request #442 from asarhaddon/mal-macro-env
Joel Martin [Wed, 21 Aug 2019 17:58:08 +0000 (12:58 -0500)]
Merge pull request #442 from asarhaddon/mal-macro-env

Mal: cosmetic improvements for envs and macros

4 years agomal: during environment lookup, convert the key to string only once.
Nicolas Boulenguez [Wed, 21 Aug 2019 08:23:24 +0000 (10:23 +0200)]
mal: during environment lookup, convert the key to string only once.

4 years agomal: improve efficiency of macro expansion
Nicolas Boulenguez [Sun, 18 Aug 2019 08:15:34 +0000 (10:15 +0200)]
mal: improve efficiency of macro expansion

Spare 4 environment creations during macro expansion.

4 years agomal: when looking up a macro in the env stack, only traverse the stack once
Nicolas Boulenguez [Sat, 17 Aug 2019 09:37:48 +0000 (11:37 +0200)]
mal: when looking up a macro in the env stack, only traverse the stack once

4 years agomal: improve consistency of indentation
Nicolas Boulenguez [Sat, 17 Aug 2019 09:28:02 +0000 (11:28 +0200)]
mal: improve consistency of indentation

4 years agoguide: make explicit that the example code can be adapted.
Nicolas Boulenguez [Tue, 20 Aug 2019 21:31:19 +0000 (23:31 +0200)]
guide: make explicit that the example code can be adapted.

4 years agoREADME update wasm MODE info.
Joel Martin [Mon, 12 Aug 2019 06:09:55 +0000 (01:09 -0500)]
README update wasm MODE info.

Also, update test count to be closer to 800.

4 years agowasm: add wasmer, lucet modes. Update wasmtime.
Joel Martin [Sat, 10 Aug 2019 22:30:56 +0000 (17:30 -0500)]
wasm: add wasmer, lucet modes. Update wasmtime.

4 years agoes6, ts: address security alerts.
Joel Martin [Thu, 8 Aug 2019 18:43:42 +0000 (13:43 -0500)]
es6, ts: address security alerts.

ts was not actually using the yarn.lock file so remove it. Update the
esm dep in es6.

4 years agodocs/graph: js-yaml vulnerability fix.
Joel Martin [Tue, 11 Jun 2019 14:57:25 +0000 (09:57 -0500)]
docs/graph: js-yaml vulnerability fix.

Not a big issue since the source of the yaml is a local data file and
this is triggered manually to generate the impl graph.

https://github.com/kanaka/mal/network/alert/docs/graph/package.json/js-yaml/open

4 years agoMerge pull request #440 from aasimk2000/add-nil-if-test
Joel Martin [Wed, 7 Aug 2019 16:47:02 +0000 (11:47 -0500)]
Merge pull request #440 from aasimk2000/add-nil-if-test

step 4: Test (if nil 1) returns nil

4 years agostep 4: Test (if nil 1) returns nil
Aasim Kandrikar [Wed, 7 Aug 2019 07:25:44 +0000 (12:55 +0530)]
step 4: Test (if nil 1) returns nil

Certain implementations like the one I wrote can get this wrong.

4 years agoMerge pull request #439 from bjh21/bjh21-perl
Joel Martin [Sun, 4 Aug 2019 19:27:15 +0000 (14:27 -0500)]
Merge pull request #439 from bjh21/bjh21-perl

Final (?) perl improvements

4 years agoperl: Add a README file containing some facts.
Ben Harris [Sun, 4 Aug 2019 16:23:26 +0000 (17:23 +0100)]
perl: Add a README file containing some facts.

4 years agoUpdate version requirement for perl.
Ben Harris [Sun, 4 Aug 2019 15:50:09 +0000 (16:50 +0100)]
Update version requirement for perl.

I don't think it's worked on perl 5.8 for a long time.

4 years agoperl: Rework 'do' to not use 'splice' and 'rest' methods.
Ben Harris [Sat, 3 Aug 2019 21:53:36 +0000 (22:53 +0100)]
perl: Rework 'do' to not use 'splice' and 'rest' methods.

I feel that it's more perly to directly use Perl's array manipulation
functions.  It's certainly more consistent with the other special forms.

4 years agoperl: Replace $a1, $a2, and $a3 in EVAL with usefully-named veriables.
Ben Harris [Tue, 30 Jul 2019 20:40:31 +0000 (21:40 +0100)]
perl: Replace $a1, $a2, and $a3 in EVAL with usefully-named veriables.

This means that most of the special forms have an assignment at the top
giving names to the members of @$ast.  I think this makes the code a
little more readable.

4 years agoperl: Use a proper Mal::Keyword type.
Ben Harris [Tue, 30 Jul 2019 19:41:13 +0000 (20:41 +0100)]
perl: Use a proper Mal::Keyword type.

Representing a keyword as a Mal::String with a magic first character was
beginning to annoy me, so instead create a proper Mal::Keyword class.
To support using both Mal::String and Mal::Keyword as hash keys,
overload stringification on all Mal::Scalar subclasses.

This means that now instead of a Mal::String stringifying to something
like "Mal::String=SCALAR(0x5744ea58)", it will stringify to something
more like "Mal::String abc", which is readable, has the correct
properties for a hash-map key, and is easy to convert back into a
Mal::String.

This turns out to work perfectly well, and entirely accidentally
arranges that 'keyword' now works properly when fed a keyword as input.

4 years agomake: revert/correct fix for plain undef symbol.
Joel Martin [Fri, 2 Aug 2019 17:44:22 +0000 (12:44 -0500)]
make: revert/correct fix for plain undef symbol.

The return value from _error was causing some breakage in other error
handling. Instead, return a value from the spot where the undefined
symbol error is set. This achieves the desired fix without breaking
other unclosed sequence errors.

4 years agograph: update bbc-basic. Exclude more from LOC.
Joel Martin [Fri, 2 Aug 2019 16:39:18 +0000 (11:39 -0500)]
graph: update bbc-basic. Exclude more from LOC.

Pull in bbc-basic update that allows loccount to properly count the
files.
Exclude more documentation and configuration files from LOC counts.

4 years agoMerge pull request #438 from bjh21/bjh21-bbc-basic
Joel Martin [Fri, 2 Aug 2019 15:44:48 +0000 (10:44 -0500)]
Merge pull request #438 from bjh21/bjh21-bbc-basic

bbc-basic: Switch to filenames ending ".bas".

4 years agobbc-basic: Changes consequent upon file renaming.
Ben Harris [Thu, 1 Aug 2019 22:24:40 +0000 (23:24 +0100)]
bbc-basic: Changes consequent upon file renaming.

To allow the same BASIC source (and in particular, LIBRARY statements)
to work on both Unix and RISC OS (the latter of which doesn't allow '.'
in file names), create symlinks to all the libraries from their
unadorned names.

4 years agobbc-basic: Rename all files of BASIC code to *.bas.
Ben Harris [Thu, 1 Aug 2019 22:22:53 +0000 (23:22 +0100)]
bbc-basic: Rename all files of BASIC code to *.bas.

This should help things to recognise what they are.  Consequential
amendments in the next commit.

This also removes toktest, which is unnecessary now.

4 years agograph: BASICs are statically typed.
Joel Martin [Wed, 31 Jul 2019 18:58:31 +0000 (13:58 -0500)]
graph: BASICs are statically typed.

4 years agodocs/graph: add bbc-basic, vala. General updates.
Joel Martin [Wed, 31 Jul 2019 17:11:53 +0000 (12:11 -0500)]
docs/graph: add bbc-basic, vala. General updates.

Incorporates fixed LOC stats that correctly ignores steps 0-9 and
ignores generated files and external downloaded dependencies.

4 years agostats: exclude steps 0-9 & generated/extern files
Joel Martin [Wed, 31 Jul 2019 05:10:27 +0000 (00:10 -0500)]
stats: exclude steps 0-9 & generated/extern files

4 years agomake: fix catch of undefined plain symbol
Joel Martin [Wed, 31 Jul 2019 05:06:37 +0000 (00:06 -0500)]
make: fix catch of undefined plain symbol

The _error function was returning an empty string which meant that in
the try*/catch* implementation, the lack of result was preventing
foreach from being used as a "let" form and because of that it was
skipping the catch* handling path.

4 years agoMerge pull request #359 from bjh21/bjh21-unterminated-strings
Joel Martin [Wed, 31 Jul 2019 14:24:08 +0000 (09:24 -0500)]
Merge pull request #359 from bjh21/bjh21-unterminated-strings

New test for reading an unterminated string that nonetheless ends with a quotation mark

4 years agoMerge pull request #436 from dubek/vhdl-fix-unterminated-strings
Joel Martin [Wed, 31 Jul 2019 14:22:23 +0000 (09:22 -0500)]
Merge pull request #436 from dubek/vhdl-fix-unterminated-strings

vhdl: Fix reading of unterminated strings that happen to end with '"'.

4 years agovhdl: Fix reading of unterminated strings that happen to end with '"'.
Dov Murik [Wed, 31 Jul 2019 12:11:34 +0000 (15:11 +0300)]
vhdl: Fix reading of unterminated strings that happen to end with '"'.

Issue #359

4 years agofactor: detect unclosed strings.
Joel Martin [Wed, 31 Jul 2019 04:58:48 +0000 (23:58 -0500)]
factor: detect unclosed strings.

Detect strings that are not properly terminated.

4 years agoperl6, r, skew: detect unclosed strings.
Joel Martin [Wed, 31 Jul 2019 04:46:36 +0000 (23:46 -0500)]
perl6, r, skew: detect unclosed strings.

Detect strings that are not properly terminated.

4 years agoswift: detect unclosed strings.
Joel Martin [Wed, 31 Jul 2019 03:36:40 +0000 (22:36 -0500)]
swift: detect unclosed strings.

Detect strings that are not properly terminated.

4 years agowasm: check for invalid string in read_form
Joel Martin [Wed, 31 Jul 2019 04:10:44 +0000 (23:10 -0500)]
wasm: check for invalid string in read_form

4 years agorpython, swift3, wasm: detected unclosed strings.
Joel Martin [Wed, 31 Jul 2019 03:26:50 +0000 (22:26 -0500)]
rpython, swift3, wasm: detected unclosed strings.

Detect more cases where strings are unterminated.

4 years agoguile, matlab, nim, ps: detected unclosed strings.
Joel Martin [Wed, 31 Jul 2019 03:26:18 +0000 (22:26 -0500)]
guile, matlab, nim, ps: detected unclosed strings.

Detect more cases where strings are unterminated.

4 years agocoffee, dart, elixir, elm: detect unclosed strings.
Joel Martin [Wed, 31 Jul 2019 03:25:17 +0000 (22:25 -0500)]
coffee, dart, elixir, elm: detect unclosed strings.

Detect more cases of strings being unterminated.

4 years agoMerge pull request #435 from bjh21/bjh21-perl
Joel Martin [Tue, 30 Jul 2019 15:16:40 +0000 (10:16 -0500)]
Merge pull request #435 from bjh21/bjh21-perl

perl: New metadata and TCO and other changes

4 years agoperl: Remove a temporary variable in functions defined by 'fn*'.
Ben Harris [Tue, 30 Jul 2019 09:08:13 +0000 (10:08 +0100)]
perl: Remove a temporary variable in functions defined by 'fn*'.

I'm in favour of meaningful names for the members of @_, but naming a
reference to @_ "$args" really doesn't gain much.

4 years agoperl: Use // instead of ?: when evaluating "else" clause of 'if'.
Ben Harris [Tue, 30 Jul 2019 08:59:32 +0000 (09:59 +0100)]
perl: Use // instead of ?: when evaluating "else" clause of 'if'.

4 years agoperl: Simplify string unescaping code.
Ben Harris [Mon, 29 Jul 2019 23:56:11 +0000 (00:56 +0100)]
perl: Simplify string unescaping code.

4 years agoperl: Sightly simplify 'swap!'.
Ben Harris [Mon, 29 Jul 2019 23:43:54 +0000 (00:43 +0100)]
perl: Sightly simplify 'swap!'.

4 years agoperl: Use '//' operator to make pr_str slightly simpler.
Ben Harris [Mon, 29 Jul 2019 23:25:17 +0000 (00:25 +0100)]
perl: Use '//' operator to make pr_str slightly simpler.

4 years agoperl: Use pairmap to make printing hash-maps simpler.
Ben Harris [Mon, 29 Jul 2019 23:21:56 +0000 (00:21 +0100)]
perl: Use pairmap to make printing hash-maps simpler.

Also tidy up printing code for sequences a little.

4 years agoperl: Use more string interpolation in the printer.
Ben Harris [Mon, 29 Jul 2019 23:07:43 +0000 (00:07 +0100)]
perl: Use more string interpolation in the printer.

4 years agoperl: Avoid substr in favour of $1 and $'.
Ben Harris [Mon, 29 Jul 2019 23:02:56 +0000 (00:02 +0100)]
perl: Avoid substr in favour of $1 and $'.

It just seems more perlish to use regexps where they're sensible.

4 years agoperl: Remove experimental given/when syntax from interop.pm.
Ben Harris [Mon, 29 Jul 2019 23:01:15 +0000 (00:01 +0100)]
perl: Remove experimental given/when syntax from interop.pm.

It doesn't gain anything over for/if, and removing it avoids a warning.

4 years agoperl: Avoid excessive copying in Mal::Sequence::rest and ::slice.
Ben Harris [Mon, 29 Jul 2019 19:54:02 +0000 (20:54 +0100)]
perl: Avoid excessive copying in Mal::Sequence::rest and ::slice.

There's no need to copy the input into @arr and then copy the bits we
care about into the output array.

4 years agoperl: Replace _string_Q with ->isa('Mal::String') && !->isa('Mal::Keyword')
Ben Harris [Mon, 29 Jul 2019 19:43:29 +0000 (20:43 +0100)]
perl: Replace _string_Q with ->isa('Mal::String') && !->isa('Mal::Keyword')

That's a bit ugly, but it gets rid of the last type-predicate function.

4 years agoperl: Replace _keyword with Mal::Keyword->new.
Ben Harris [Mon, 29 Jul 2019 19:36:12 +0000 (20:36 +0100)]
perl: Replace _keyword with Mal::Keyword->new.

It's not really a constructor for Mal::Keyword (because there's no such
class), but it looks similar enough for most purposes.

4 years agoperl: Replace _keyword_Q with ->isa('Mal::Keyword').
Ben Harris [Mon, 29 Jul 2019 19:26:19 +0000 (20:26 +0100)]
perl: Replace _keyword_Q with ->isa('Mal::Keyword').

There isn't actually a Mal::Keyword class, but perl lets us override
"isa" so we can pretend there is.

4 years agoperl: Enhance Mal::HashMap::new to take an array reference. Use this.
Ben Harris [Sun, 28 Jul 2019 22:50:22 +0000 (23:50 +0100)]
perl: Enhance Mal::HashMap::new to take an array reference.  Use this.

This replaces _hash_map and has the nice feature that it looks just like
the constructors for Mal::List and Mal::Vector, so the reader can treat
them all the same.

4 years agoperl: Abolish most of the type predicates in favour of ->isa().
Ben Harris [Sun, 28 Jul 2019 16:58:07 +0000 (17:58 +0100)]
perl: Abolish most of the type predicates in favour of ->isa().

_string_Q and _keyword_Q survive because they distinguish two mal types
that are represented by the same Perl class.

4 years agoperl: Abolish most of the complexity of function classes.
Ben Harris [Sun, 28 Jul 2019 15:52:49 +0000 (16:52 +0100)]
perl: Abolish most of the complexity of function classes.

Now there's just Mal::Function, which is the old Mal::CoreFunction.
Macros are represented by Mal::Macro, a different subclass of the same
parent.

4 years agoperl: Use goto &NAME for tail-call optimisation.
Ben Harris [Sat, 27 Jul 2019 20:35:30 +0000 (21:35 +0100)]
perl: Use goto &NAME for tail-call optimisation.

This is rather contrary to the guide, which expects a loop in EVAL, but
perl is unusual in having native support for (manual) tail-call
optimisation and it would seem a shame not to take advantage of this.

This leaves macros broken since all functions are now implemented as
core functions, and we don't yet have support for turning them into
macros.

4 years agoperl: Convert sequences into blessed array references.
Ben Harris [Sat, 27 Jul 2019 09:30:45 +0000 (10:30 +0100)]
perl: Convert sequences into blessed array references.

The extra hash was only used to hold metadata.

4 years agoperl: Remove FunctionRef class.
Ben Harris [Sat, 27 Jul 2019 09:28:15 +0000 (10:28 +0100)]
perl: Remove FunctionRef class.

Now that metadata can be attached to a CoreFunction, there's no need
for the proxy class.

4 years agoperl: Convert atoms into simple scalar references.
Ben Harris [Sat, 27 Jul 2019 09:24:46 +0000 (10:24 +0100)]
perl: Convert atoms into simple scalar references.

4 years agoperl: Replace _clone() with a ->clone method.
Ben Harris [Sat, 27 Jul 2019 09:20:47 +0000 (10:20 +0100)]
perl: Replace _clone() with a ->clone method.

This means that each class is responsible for cloning itself, which
helps with encapsulation.

4 years agoperl: Simplify hash-map implementation.
Ben Harris [Sat, 27 Jul 2019 09:03:55 +0000 (10:03 +0100)]
perl: Simplify hash-map implementation.

Now that metadata is external, we can remove the layer of indirection
in the HashMap class and have the top-level hash contain the hash-map
contents.

4 years agoperl: Remove old metadata implementation.
Ben Harris [Fri, 26 Jul 2019 00:41:06 +0000 (01:41 +0100)]
perl: Remove old metadata implementation.

Several objects are now single-member hashes, which is obviously silly.

4 years agoperl: Introduce fieldhash-based metadata implementation.
Ben Harris [Fri, 26 Jul 2019 00:24:44 +0000 (01:24 +0100)]
perl: Introduce fieldhash-based metadata implementation.

Rather than attaching metadata directly to objects, hold it in a
auxiliary hash keyed by object ID.  Perl's Hash::Util::FieldHash
provides a means to do this with proper garbage-collection.  This does
mean that cloning an object no longer brings its metadata along, but I
think the only use of _clone outside of attaching metadata is to make
macros, and (for now) mal doesn't require that 'defmacro!' preserve
metadata.

This commit only adds the new metadata system.  Most of the old one is
still lying around.

4 years agoperl: Replace _sequential_Q in step files with ->isa('Mal::Sequence').
Ben Harris [Sun, 28 Jul 2019 09:58:57 +0000 (10:58 +0100)]
perl: Replace _sequential_Q in step files with ->isa('Mal::Sequence').

4 years agoSkip perf for second-order self-hosted tests.
Joel Martin [Mon, 29 Jul 2019 23:20:11 +0000 (18:20 -0500)]
Skip perf for second-order self-hosted tests.

4 years agoFix second-order self-hosting.
Joel Martin [Mon, 29 Jul 2019 22:55:25 +0000 (17:55 -0500)]
Fix second-order self-hosting.

The `_map?` function was introduced when transitioning the macro
property being stored in metadata to uinsg a regular map with
a special key. The `_map?` function causes issues in a few places but
the biggest issue is that it breaks the `_macro?` function for the
second order self-hosted mal instance. The `_macro?` function contains
a `(map? x)` call that returns false resulting in the `_macro?` call
returning false.  I'll push something later that fixes this and also
that activates second order self-hosted tests so we can catch this
sort of issue in the future.

4 years agoMerge pull request #387 from asarhaddon/test-macroexpand-no-quasiquote
Joel Martin [Mon, 29 Jul 2019 22:53:55 +0000 (17:53 -0500)]
Merge pull request #387 from asarhaddon/test-macroexpand-no-quasiquote

test macroexpand without assuming that quasiquote is a special form

4 years agoMerge pull request #415 from asarhaddon/load-file-trailing-new-line-nil
Joel Martin [Mon, 29 Jul 2019 22:42:26 +0000 (17:42 -0500)]
Merge pull request #415 from asarhaddon/load-file-trailing-new-line-nil

load-file: accept final comment without new line, return nil

4 years agoJava: fix escaping of '/'.
Joel Martin [Mon, 29 Jul 2019 14:15:17 +0000 (09:15 -0500)]
Java: fix escaping of '/'.

Switch to escapeJava which won't do escaping of forward slash.

4 years agoMerge pull request #432 from bjh21/bjh21-perl
Joel Martin [Mon, 29 Jul 2019 14:08:48 +0000 (09:08 -0500)]
Merge pull request #432 from bjh21/bjh21-perl

More perl improvements

4 years agoMerge pull request #433 from bendudson/fix-nasm-empty-args
Joel Martin [Mon, 29 Jul 2019 14:04:08 +0000 (09:04 -0500)]
Merge pull request #433 from bendudson/fix-nasm-empty-args

Fix nasm zero argument function call

4 years agoApplying changes to step6 - stepA
Ben Dudson [Sun, 28 Jul 2019 16:15:41 +0000 (17:15 +0100)]
Applying changes to step6 - stepA

Tested stepA, function with empty args still working.

4 years agoFix step 5 call function no args
Ben Dudson [Sun, 28 Jul 2019 16:03:55 +0000 (17:03 +0100)]
Fix step 5 call function no args

Previously failed on
```
((fn* () 4))

```
due to freeing the list containing the function too early.

4 years agoperl: Simplified and tightened implementation of 'try*'.
Ben Harris [Sun, 28 Jul 2019 11:43:12 +0000 (12:43 +0100)]
perl: Simplified and tightened implementation of 'try*'.

This also fixes a bug where the last character of the stringification of
an exception object might get removed.

4 years agoperl: Remove _nil_Q(), _true_Q(), and _false_Q().
Ben Harris [Sun, 28 Jul 2019 10:20:14 +0000 (11:20 +0100)]
perl: Remove _nil_Q(), _true_Q(), and _false_Q().

They were almost unused, and 'eq' is slightly more self-explanatory.

4 years agoload-file: accept empty file or final comment, return nil
Nicolas Boulenguez [Mon, 15 Jul 2019 21:57:02 +0000 (23:57 +0200)]
load-file: accept empty file or final comment, return nil

Let `load-file` append a new line in case last line contains a
comment.

Also append `nil` so that the return value is predictible. Remove the
existing explicit `nil` from existing sources.

Adapt documentation and tests.

4 years agoperl: Polish _equal_Q a little.
Ben Harris [Sun, 28 Jul 2019 09:49:00 +0000 (10:49 +0100)]
perl: Polish _equal_Q a little.

It now uses "unless" rather than "if", uses "isa" rather than
_sequential_Q, doesn't bother with temporary variables for the types
of the arguments, and doesn't special-case symbols.

4 years agoperl: Re-FATALise the "recursion" warning from step 5 onwards.
Ben Harris [Sun, 28 Jul 2019 09:13:49 +0000 (10:13 +0100)]
perl: Re-FATALise the "recursion" warning from step 5 onwards.

The step 5 tests expect that deep recursion will cause an exception, and
not just a warning, so they can prove that TCO is working properly.

4 years agoperl: Use "foreach" for variable bindings in Mal::Env::new.
Ben Harris [Sun, 28 Jul 2019 09:13:44 +0000 (10:13 +0100)]
perl: Use "foreach" for variable bindings in Mal::Env::new.

4 years agoperl: Move 'pl*' to core.pm.
Ben Harris [Sat, 27 Jul 2019 23:46:17 +0000 (00:46 +0100)]
perl: Move 'pl*' to core.pm.

The guide says that 'quux-eval', which the perl implementation calls
'pl*', should be a core function.  I can't see any good reason why it
shouldn't be, so I've turned it into one.

4 years agoperl: De-FATALise warnings.
Ben Harris [Sat, 27 Jul 2019 23:23:28 +0000 (00:23 +0100)]
perl: De-FATALise warnings.

The documentation says, 'the use of "FATAL => 'all'" is discouraged', so
it better to leave them non-fatal.

4 years agoperl: Tidy up imports at the top of each file.
Ben Harris [Sat, 27 Jul 2019 23:19:13 +0000 (00:19 +0100)]
perl: Tidy up imports at the top of each file.

I kept not knowing where to add things, so I've roughly sorted them into
pragmas, then external modules, then internal modules.  This helps with
the situation that internal modules are named in lower case, which is
odd for Perl (but normal for mal).

4 years agoperl: Remove step 0.5.
Ben Harris [Sat, 27 Jul 2019 23:05:16 +0000 (00:05 +0100)]
perl: Remove step 0.5.

It seems to be just a less-complete version of step 0.

4 years agoperl: Simplify call to Mal::Env->new in 'catch*'.
Ben Harris [Sat, 27 Jul 2019 13:51:08 +0000 (14:51 +0100)]
perl: Simplify call to Mal::Env->new in 'catch*'.

Mal::Env->new doesn't need its array references to be blessed, so just
pass them plain.  This saves a bit of messing about with Mal::List->new.