1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-20 01:57:09 +03:00
Commit Graph

3863 Commits

Author SHA1 Message Date
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
Joel Martin
05ce97f3c7
PR template: fix typo 2024-08-27 15:06:55 -05:00
Joel Martin
6deaeb268f Add PR template. New impl checklist in template and FAQ 2024-08-27 15:04:47 -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
Nicolas Boulenguez
c5788b3790 purs: merge evalAst into eval and add DEBUG-EVAL
See #592 for context.
2024-08-26 12:56:33 -05:00
Dov Murik
1354b3fe9c jq: Remove stray _debug call in nth implementation 2024-08-26 10:10:44 -05:00
Dov Murik
f7ab284599 jq: Fix functions with empty list body
jq's find_free_references failed on empty lists; add handling for that
case.

Add relevant test in step4.
2024-08-26 10:10:44 -05:00
Nicolas Boulenguez
dab788cf4f lua: style improvements, especially for try* 2024-08-26 10:00:47 -05:00
Nicolas Boulenguez
a9456d0179 lua: simplify and debug environments
Use plain LUA strings as keys in environments.
Search outers environments with a loop.
Remove the now unneeded Env:find trick.
Let DEBUG-EVAL show the contents of all outer environments but repl_env.
2024-08-26 10:00:47 -05:00
Nicolas Boulenguez
ae91e2b0af lua: remove some unneeded imports 2024-08-26 10:00:47 -05:00
Nicolas Boulenguez
b4244ddb09 lua: prevent defmacro! from mutating the original function 2024-08-26 10:00:47 -05:00
Nicolas Boulenguez
69d7d8d120 lua: prevent vec from mutating the original list 2024-08-26 10:00:47 -05:00
Nicolas Boulenguez
9a22e8a653 lua: merge eval and eval AST 2024-08-26 10:00:47 -05:00
Nicolas Boulenguez
56252444c8 lua: remove a safe but unneeded code line from Env::new 2024-08-26 10:00:47 -05:00
Nicolas Boulenguez
f15b7b4f10 lua: introduce a printer._pr_seq helper 2024-08-26 10:00:47 -05:00
Nicolas Boulenguez
15c7be28ec lua: improve consistency of keyword handling 2024-08-26 10:00:47 -05:00
Nicolas Boulenguez
91f2156ae6 lua: call hash_map instead of reimplementing it 2024-08-26 10:00:47 -05:00
Nicolas Boulenguez
3e8079e7b1 lua: simplify Makefile 2024-08-26 10:00:47 -05:00
Nicolas Boulenguez
309731037e lua: update Dockerfile 2024-08-26 10:00:47 -05:00
Joel Martin
74efdd942e README: fix mode after python2/python3 renaming 2024-08-26 09:58:34 -05:00
Nicolas Boulenguez
688503d2cc Rename python implementations to python2 and python3, see #665 2024-08-26 09:57:14 -05:00
Nicolas Boulenguez
87b283a350 python.2: fix tests, use source checkers and more python3 features
Check the whole code with flake8, pylint and mypy.

Report all possible errors with extensive context.

Demonstrate iterators, decorators, functional tools, chain maps,
dataclasses, match statements, assignments expressions.

Implement environments with python chain maps.

Rewrite the reader without external dependencies (but inspired by the
ptk library).  The motivation was that no external library is fully
type-checked for now.

Avoid name clashes when possible (print, read, readline, types).

Write the readline history file at exit, not after each prompt.

Replace printer.pr_str as methods of MAL objects.  This is idiomatic
python, and improves the error reporting.

Change some representations so that the python equality matches the
MAL equality.  The recursion is now implicit.

Remove -O from ./run.  It took me a while to understand that run-time
assertions were disabled!  MAL is about development, not performance.

Dispatch the special forms from a dict, for readability (pylint
rightfully complains that there are too many return statements in
eval_()).

Copy the recursion overflow fix, the python interaction from the first
python implementation.

Add tests detecting that nil false 0 () [] "" are distinct, and that 0
() are not False when tested (in python False == 0 and an empty
container is tested ).

Add tests checking that metadata does not affect equality (they do
with a naive python dataclass).
2024-08-24 10:16:32 -05:00
老刘
db7c10a689 vbs: remove NO_SELF_HOST for run self-host test on Github Action 2024-08-24 10:05:34 -05:00
老刘
3e040b4946 vbs: modify run for Github Action test 2024-08-24 10:05:34 -05:00