asm: values + call-with-values + #(...) reader + exit + vector equal?
Closes the remaining asm-side gaps from ticket 0005's follow-up
discussion. Every test in tests/cl-compat.lsp and tests/ursa.lsp
now runs unmodified on default asm (Scheme port) and asm-full (full
CL path) — no more commented-out tests or shim syntax.
Landed (all in default asm — useful beyond cl-compat):
* (values . xs) / (call-with-values producer consumer). values
packs a tagged pair (mval_marker . xs) when multiple; a lone arg
passes through unchanged so legacy single-value code is
undisturbed. call-with-values invokes the producer, destructures
the multi-value packet if present, applies consumer positionally.
The marker is a gensymed symbol interned once at init, so no
user-constructed pair can masquerade as a multi-value packet.
* (exit [code]) builtin. Default code is 0 when called with no
args. Passes through to the SYS_EXIT syscall.
* #(...) vector literal in the reader. .sr_hash now dispatches on
'(' as a vector literal alongside 't' and 'f'. list_to_vector_
reader is a standalone helper callable from the reader (separate
from bi_listtovec which uses the GETARG builtin convention).
Matches R7RS vector literal syntax. Existing vector builtins
already handled construction; this just teaches the reader.
* deep_equal extended to vectors. equal? now descends into vectors
(length + elementwise recursive compare), matching R7RS.
Previously only strings and pairs were handled; vectors fell
through to shallow pointer compare which only matched identical
heap objects.
Test file reverts (picking up the new capabilities):
* tests/cl-compat.lsp — multiple-value-bind test restored
(previously commented out because asm lacked values /
call-with-values).
* tests/ursa-scheme.lsp — #(1 0 1 0 1 0) literal restored
(previously worked around with (vector->list (digits ...)));
(exit 1) failure trailer restored (previously removed because
asm had no exit builtin).
* tests/ursa.lsp — same digits literal restoration.
Verified:
* asm regression: 158/158.
* asm-full regression: 158/158.
* Zoë-favorites across Python + C + asm + asm-full: all suites
green with native reader syntax and multi-value tests.
* make test-all stays green.
This commit is contained in:
parent
2061cb169a
commit
99b0622520
10 changed files with 202 additions and 23 deletions
|
|
@ -79,12 +79,9 @@
|
|||
25)
|
||||
|
||||
;; ── multiple-value-bind ──────────────────────────────────────────
|
||||
;; Skipped on tiers without `values` / `call-with-values` (asm).
|
||||
;; Python and C both ship them as builtins. The macro itself is
|
||||
;; validated at the other tiers.
|
||||
;; (check "mvb"
|
||||
;; (multiple-value-bind (q r) (values 7 3) (list q r))
|
||||
;; '(7 3))
|
||||
(check "mvb"
|
||||
(multiple-value-bind (q r) (values 7 3) (list q r))
|
||||
'(7 3))
|
||||
|
||||
;; ── cl-loop: 14 representative patterns ─────────────────────────
|
||||
|
||||
|
|
|
|||
|
|
@ -30,12 +30,7 @@
|
|||
(check "s:ll-primep-11" (lucas-lehmer-primep 11) #f)
|
||||
(check "s:ll-primep-13" (lucas-lehmer-primep 13) #t)
|
||||
(check "s:repunit-5" (repunit-value 5) 31)
|
||||
;; Verify digits via vector->list so the comparison is over lists
|
||||
;; (asm's equal? does not descend into vectors — lists are shared
|
||||
;; across every tier's deep-equal path).
|
||||
(check "s:digits-42-2"
|
||||
(vector->list (digits 42 2))
|
||||
'(1 0 1 0 1 0))
|
||||
(check "s:digits-42-2" (digits 42 2) #(1 0 1 0 1 0))
|
||||
(check "s:digits-roundtrip" (digits (digits 1234 16) 16) 1234)
|
||||
(let ((v (of-n-bits 8)))
|
||||
(check "s:of-n-bits" (and (>= v 128) (< v 256)) #t))
|
||||
|
|
@ -43,3 +38,4 @@
|
|||
(display "══════════════════════════════") (newline)
|
||||
(display "ursa-scheme: ") (display *pass*) (display " passed, ")
|
||||
(display *fail*) (display " failed") (newline)
|
||||
(if (> *fail* 0) (exit 1))
|
||||
|
|
|
|||
|
|
@ -31,9 +31,7 @@
|
|||
(check "s:ll-primep-11" (lucas-lehmer-primep 11) #f)
|
||||
(check "s:ll-primep-13" (lucas-lehmer-primep 13) #t)
|
||||
(check "s:repunit-5" (repunit-value 5) 31)
|
||||
(check "s:digits-42-2"
|
||||
(vector->list (digits 42 2))
|
||||
'(1 0 1 0 1 0))
|
||||
(check "s:digits-42-2" (digits 42 2) #(1 0 1 0 1 0))
|
||||
(check "s:digits-roundtrip" (digits (digits 1234 16) 16) 1234)
|
||||
(let ((v (of-n-bits 8)))
|
||||
(check "s:of-n-bits" (and (>= v 128) (< v 256)) #t))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue