Skip to content

Extend - #8

Merged
NJdevPro merged 5 commits into
masterfrom
extend
Nov 11, 2026
Merged

NJdevPro merged 5 commits into
masterfrom
extend

Conversation

@NJdevPro

Copy link
Copy Markdown
Owner

Bug fixes and optimizations by Claude Code.

NJdevPro and others added 5 commits November 11, 2026 14:58
Bug fixes:
- REPL and --exec passed the input text as GC root instead of gc_root,
  crashing as soon as a GC happened.
- MINILISP_ALWAYS_GC was never honored (flags were only read inside gc());
  they are now read in gc_init(). This exposed more stale-pointer bugs:
  init_minilisp used a NULL root, symbol->string and string->symbol copied
  from a moved object, and load kept a pointer to the filename in the heap
  and dropped the caller's root chain.
- Arithmetic: division by zero, (+), (-) and untyped first argument no
  longer crash; overflow wraps instead of being undefined behaviour.
- Numbers >= 2^31 were truncated by the reader (int accumulator); detect
  overflow instead.
- atom now evaluates its argument; reverse no longer modifies its
  arguments (lists and strings); (car), (cdr), (println) and (load) with
  missing arguments no longer crash; extra function arguments are an error.
- eval_list no longer clobbers the caller's list slot (line numbers in
  error messages were 0).
- Reader: correct line counting for CRLF files, EOF/NUL handling, bad dot
  syntax, improper argument lists.
- Recursion that is too deep reports a Lisp error instead of SEGV.
- repl: options may follow file names (-r was loaded as a file), Ctrl-D
  exits the REPL instead of looping forever.

Performance:
- Look up the head symbol once per call instead of twice.
- while uses progn instead of building a throwaway list.
- Preallocated small integers (-128..1023); eq compares integers by value.
- GC keeps two semi-spaces instead of mmap/munmap on every collection,
  and grows the heap when more than half is live after a GC.
- Reader works on a buffer instead of stdio/fmemopen/stdin hijacking.
- string-concat is linear.

error() is now noreturn and checked as a printf-like function.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A relative path given to (load ...) is first looked up in the directory of
the file being loaded, then in the current directory, so that examples can
load their library regardless of where minilisp is started from.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
print and println now print all their arguments separated by a space,
as documented in the original README, instead of ignoring all but the
first one. Tests added for both.

README: document strings, *, /, mod, the command line options, the REPL
commands, the load path resolution, the stack overflow error and the GC
debugging variables; fix outdated or wrong statements (eq, if, reverse,
recursion limits, load example path) and unbalanced examples.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…/tasks.json to be relative to the workspace folder instead of the current file. This allows the tasks to work when the workspace is opened from a different location.
@NJdevPro
NJdevPro merged commit 53f6bc7 into master Nov 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant