1
1
mirror of https://github.com/kanaka/mal.git synced 2024-10-05 18:08:55 +03:00
Commit Graph

553 Commits

Author SHA1 Message Date
Joel Martin
cc1ebff5e8 hy: merge eval_ast/macroexpand into EVAL. Add DEBUG-EVAL.
Original issue describing the change and converting the first set of
implementations: https://github.com/kanaka/mal/pull/592

Tracking issue for other implementations: https://github.com/kanaka/mal/issues/657
2024-09-20 11:31:41 -04:00
Nicolas Boulenguez
454d635109 ada.2: fix environments for closures 2024-09-19 18:03:57 -04:00
Nicolas Boulenguez
a645b468f8 nim: mark several variables as immutable
Also apply 2dedaa3919 to step0
2024-09-19 18:03:57 -04:00
Nicolas Boulenguez
c7a984ea0a nim: update Dockerfile and fix new compiler warnings 2024-09-19 18:03:57 -04:00
Nicolas Boulenguez
0fd323785c Two new tests for closures 2024-09-19 18:03:57 -04:00
Nicolas Boulenguez
4225052a28 latex3: fix one more time-ms overflow 2024-09-19 18:03:06 -04:00
Joel Martin
1c5ac14e05 zig: move zig unpack path from /mal to /opt 2024-09-19 14:48:19 -04:00
Nicolas Boulenguez
0a24696ae1 zig: simplify the reader, fix a memory leak 2024-09-19 14:48:19 -04:00
Nicolas Boulenguez
8c7d495eea zig: build with 0.13.0, merge eval_ast, fix remaining issues
Update build system, syntax and library calls for zig 0.13.0.

Rewrite the build system so that the steps can build separately.  Drop
intermediate symbolic links (unneeded complexity, confusing
timestamps).

Build with debugging options, this is a toy project full of memory
leaks.

Declare the allocators as global variables instead of passing and/or
storing always the same reference everywhere for no benefit.

Make apply_function a global variable instead of adding a reference to
EVAL in each function.

Pass arguments as a slice instead of using a different type for each
argument count.

There is no point in renaming default errors.

Remove a lot of reference counting and some indirection levels.
This fixes the current segmentation faults.

Create each object as soon as possible and use errdefer so that it is
deallocated if an exception occurs when computing its elemements.

Use a global variable to convey a MAL object alongside a thrown error.

Remove the unused logging_alloc module (but add a debug_alloc boolean
in types.zig).
2024-09-19 14:48:19 -04:00
Loredana Cirstea
fbee4ec615 wasm: add seq 2024-09-06 08:49:42 -04:00
Vasilij Schneidermann
43ae30f21a chuck: Fix soft-fail for with-meta 2024-08-29 01:58:05 +02:00
Vasilij Schneidermann
5891315a98 chuck: Improve error handling 2024-08-29 01:58:05 +02:00
Vasilij Schneidermann
6002edd9bd chuck: Remove remnants of boxed types 2024-08-29 01:58:05 +02:00
Vasilij Schneidermann
78bd99f2fd chuck: Add DEBUG-EVAL 2024-08-29 01:58:05 +02:00
Vasilij Schneidermann
02299daa5c chuck: Rework internal representation for perf 2024-08-28 23:08:05 +02:00
Vasilij Schneidermann
665471a8d6 chuck: Update to ChucK 1.5.2.5 2024-08-28 23:08:05 +02:00
Joel Martin
2dedaa3919 nim: exit on Ctrl-D in steps 1-8
step9 and stepA had a catch handler for this but the earlier steps were
missing it.
2024-08-28 09:35:42 -05:00
Joel Martin
4c7b1d6af0 nim: fix env binding in steps 3 & 4
In step4 the following fails to return 0:
    ```
    (let* [b 0 f (fn* [] b)] (let* [b 1] (f)))
    ```

Just use the initEnv initializer in steps 3 and 4 (following the same
pattern used by step 5 on onwards).
2024-08-28 09:35:42 -05:00
Nicolas Boulenguez
8406b21f84 wasm: remove the now unneeded ENV_FIND environment method 2024-08-28 08:52:14 -05:00
Nicolas Boulenguez
87b0b23970 perl: backport all recent style changes from stepA to previous steps 2024-08-27 15:19:20 -05:00
Nicolas Boulenguez
4e02e6231e perl: capitalize the modules 2024-08-27 15:19:20 -05:00
Nicolas Boulenguez
7c1238c1e7 perl: use perl conventions for env.pm
In Perl, a class should be alone in a module, with a capitalized name
(Mal::Env would require a subdirectory).
2024-08-27 15:19:20 -05:00
Nicolas Boulenguez
ca88d3ad8f perl: replace package variables for nil true false with functions
See critic: Variables::ProhibitPackageVars.
2024-08-27 15:19:20 -05:00
Nicolas Boulenguez
2a5d5ee207 perl: remove some hacks for sequence and hash functions
These changes arguably improve the readability by reducing the
implicit interface between types.pm and core.pm..
2024-08-27 15:19:20 -05:00
Nicolas Boulenguez
292a758dd9 perl: remove obsolete clone method for atoms 2024-08-27 15:19:20 -05:00
Nicolas Boulenguez
2d190718f7 perl: search for special forms with a hashed jump
Perlcritic find this prettier than a cascade of tests.
2024-08-27 15:19:20 -05:00
Nicolas Boulenguez
72db33ec9d perl: rewrite the reader
This version is hopefully more readable.

It removes the specific exception for blank lines, which is not
required and obfuscates the repl loop for little benefit.
2024-08-27 15:19:20 -05:00
Nicolas Boulenguez
ce7c1f89e7 perl: remove experimental given/when statement 2024-08-27 15:19:20 -05:00
Nicolas Boulenguez
070fb90087 perl: more cosmetic style changes
'say' is deprecated

'--raw' must be removed before step6 checks for a MAL script file name.
2024-08-27 15:19:20 -05:00
Nicolas Boulenguez
bb70b77b78 perl: fix perl-critic issues with severity 1 2024-08-27 15:19:20 -05:00
Nicolas Boulenguez
119b4e281a perl: fix perl-critic issues with severity 2 2024-08-27 15:19:20 -05:00
Nicolas Boulenguez
32b6f981de perl: fix perl-critic issues with severity 3 2024-08-27 15:19:20 -05:00
Nicolas Boulenguez
d94f65cb93 perl: fix perl-critic issues with severity 4 2024-08-27 15:19:20 -05:00
Nicolas Boulenguez
504692f13f perl: add shebang to scripts
Else perlcritic complains about the absence of $VERSION.
2024-08-27 15:19:20 -05:00
Nicolas Boulenguez
b18f823d39 perl: clarify package imports
Remove unused dependencies.

Import explicit lists for clarity.

Avoid module::function prefixs, as some modules will be renamed
(critic: modules must be capitalized).

Add an explicit export list to core.pm, so that all symbols are not
exported by default.

Introduce a pr_list function, which is convenient and removes the need
to rename _pr_str (critic: a leading underscore means a private
function).

Uppercase core::ns (critic complains about lowercase exported
variables).
While at it, convert values to MAL functions on the fly.
2024-08-27 15:19:20 -05:00
Nicolas Boulenguez
9a80cb7a64 perl: fix perl-critic issues with severity 5
Implement env->get with a loop instead of a recursion, for readability and efficiency.

Simplify mal_readline and avoid storing empty lines in the history.
2024-08-27 15:19:20 -05:00
Nicolas Boulenguez
61f1b079f2 perl: reformat sources with perltidy 2024-08-27 15:19:20 -05:00
Nicolas Boulenguez
7502ce9bcc perl: add lint target to Makefile 2024-08-27 15:19:20 -05:00
Nicolas Boulenguez
55495852b4 mal: implement DBGEVAL without assuming that a: is a valid symbol
This does not seem worth a test, but can currently break the
self-hosting.
2024-08-27 14:05:20 -05:00
Nicolas Boulenguez
99f8b02d68 objc: prevent defmacro! from mutating its argument 2024-08-27 09:46:25 -05:00
Nicolas Boulenguez
55c28a799f objc: fix (keyword :a) 2024-08-27 09:46:25 -05:00
Nicolas Boulenguez
35166947f0 objc: print *host-language* when interactive 2024-08-27 09:46:25 -05:00
Nicolas Boulenguez
4e7b6176de objc: remove the now unneeded env.find method 2024-08-27 09:46:25 -05:00
Nicolas Boulenguez
59775ee9b7 objc: implement DEBUG-EVAL 2024-08-27 09:46:25 -05:00
Nicolas Boulenguez
ad164bfb09 objc: merge eval_ast into EVAL 2024-08-27 09:46:25 -05:00
Joel Martin
19898d7893 Update Dockerfile 2024-08-26 13:07:28 -05:00
Nicolas Boulenguez
93130921d8 powershell: select Ubuntu 16.04 Docker image 2024-08-26 13:07:28 -05:00
Nicolas Boulenguez
d4ab5e3eed powershell: merge eval-ast and fix a few tests
Fix (false? 1) and (true? 0).
Change the type of the env.{find,get,set} key to a raw string.
Merge eval-ast into EVAL.
Implement DEBUG-EVAL.
Prevent defmacro! from mutating the original function.
2024-08-26 13:07:28 -05:00
Nicolas Boulenguez
7e9db5ff00 elisp: require a recent emacs version 2024-08-26 13:07:28 -05:00
Nicolas Boulenguez
0e80e7a7db elisp: fix new tests, byte-compile, various improvements
The original motivation is to fix the new (= nil ()) and
core_apply_accepts_macros tests.
Improve speed and warnings with byte compilation.

mal/core.el:
Wrap core functions during the loop in main, instead of writing the
conversion in each line of core-ns.
Use apply built-in concatenation of last argument.
Move handling of metadata to types.el.

mal/env.el:
Represent environments as cons cells instead of vectors.

mal/func.el:
Merged into types.el, it is not a special case anymore.

mal/printer.el:
Add macro case.
Define a pr-join helper for sequences and core.el.

mal/reader.el:
Rename the tokens local variable in reader.el (compiler warning).

mal/types.el:
Use type-specific accessors returning nil for the wrong type
(structural pattern matching would be better, but is too slow).
Represent native types directly when possible, and inline some trivial
accessors.
Use dedicated records instead of vectors.
Implement metadata only when required.
Represent keywords as strings (easyer, no counterpart).

run:
Run byte-compiled version.

steps:
Backport good ideas from stepA to step1, reducing the diff between
steps for future maintenance.
Implement 'do with a simple iteration (without map and butlast).
Make the repl-env local to main (compiler warning).

Make the code more idiomatic
 * prefer loop over recursion (search in environments)
 * declare variable and reassign them when convenient (exit of the TCO loop)
 * car cdr cadr and so on instead of nth
 * remove various vector <-> list conversions.
2024-08-26 13:07:28 -05:00