~ chicken-core (master) d687da978d82336ac80d88cb78315015c3118327
commit d687da978d82336ac80d88cb78315015c3118327
Author: felix <felix@call-with-current-continuation.org>
AuthorDate: Sun Oct 4 11:42:35 2026 +0200
Commit: felix <felix@call-with-current-continuation.org>
CommitDate: Sun Oct 4 11:42:35 2026 +0200
use special form for undef'd value to save a few procedure calls
diff --git a/csi.scm b/csi.scm
index 55e60b83..f3fed611 100644
--- a/csi.scm
+++ b/csi.scm
@@ -214,7 +214,7 @@ EOF
(define history-add
(let ([vector-resize vector-resize])
(lambda (vals)
- (let ([x (if (null? vals) (##sys#void) (##sys#slot vals 0))]
+ (let ([x (if (null? vals) (##core#undefined) (##sys#slot vals 0))]
[size (##sys#size history-list)] )
(when (fx>= history-count size)
(set! history-list (vector-resize history-list (fx* 2 size))) )
@@ -223,7 +223,7 @@ EOF
x) ) ) )
(define (history-clear)
- (vector-fill! history-list (##sys#void)))
+ (vector-fill! history-list (##core#undefined)))
(define history-show
(let ((newline newline))
@@ -287,7 +287,7 @@ EOF
(set-cdr! a (list proc help)) ))
(else
(set! command-table (cons (list name proc help) command-table))))
- (##sys#void))
+ (##core#undefined))
(define default-evaluator
(let ((eval eval)
@@ -308,19 +308,19 @@ EOF
(cond ((assq cmd command-table) =>
(lambda (p)
((cadr p))
- (##sys#void) ) )
+ (##core#undefined) ) )
(else
;;XXX use `toplevel-command' to define as many as possible of these
(case cmd
((x)
(let ([x (read)])
(pretty-print (strip-syntax (expand x)))
- (##sys#void) ) )
+ (##core#undefined) ) )
((p)
(let* ([x (read)]
[xe (eval x)] )
(pretty-print xe)
- (##sys#void) ) )
+ (##core#undefined) ) )
((d)
(let* ([x (read)]
[xe (eval x)] )
@@ -340,11 +340,11 @@ EOF
((l)
(let ((fns (string-split (read-line))))
(for-each load fns)
- (##sys#void) ) )
+ (##core#undefined) ) )
((ln)
(let ((fns (string-split (read-line))))
(for-each (cut load-noisily <> printer: (lambda (x) (pretty-print x) (print* "==> "))) fns)
- (##sys#void) ) )
+ (##core#undefined) ) )
((t)
(let ((x (read)))
(receive rs (time (eval x))
@@ -363,16 +363,16 @@ EOF
(printf "editor returned with non-zero exit status ~a" r))))
((ch)
(history-clear)
- (##sys#void))
+ (##core#undefined))
((h)
(history-show)
- (##sys#void))
+ (##core#undefined))
((c)
(show-frameinfo selected-frame)
- (##sys#void))
+ (##core#undefined))
((f)
(select-frame (read))
- (##sys#void))
+ (##core#undefined))
((g)
(copy-from-frame (read)))
((s)
@@ -410,10 +410,10 @@ EOF
(print #\space help)
(print " ," (car a)) ) ) )
command-table)
- (##sys#void) )
+ (##core#undefined) )
(else
(printf "undefined toplevel command ~s - enter `,?' for help~%" form)
- (##sys#void) ) ) ) ) ) )
+ (##core#undefined) ) ) ) ) ) )
(else
(receive rs (eval form)
(history-add rs)
@@ -447,7 +447,7 @@ EOF
;; imported dynamically by bootstrap compiler
;; this can be replaced by "expand1" later
(pretty-print (strip-syntax (chicken.syntax#expand1 expr)))
- (##sys#void))))
+ (##core#undefined))))
",x1 EXP Pretty print expand1-ed expression EXP")
@@ -619,7 +619,7 @@ EOF
((bwp-object? x)
(fprintf out "broken weak pointer~%"))
((eof-object? x) (fprintf out "end-of-file object~%"))
- ((eq? (##sys#void) x) (fprintf out "unspecified object~%"))
+ ((eq? (##core#undefined) x) (fprintf out "unspecified object~%"))
((fixnum? x)
(fprintf out "exact immediate integer ~S~% #x~X~% #o~O~% #b~B"
x x x x)
@@ -749,7 +749,7 @@ EOF
(fprintf out "structure of type `~S':~%" (##sys#slot x 0))
(descseq #f ##sys#size ##sys#slot 1) ) ) ) )
(else (fprintf out "unknown object~%")) )
- (##sys#void) ) ) )
+ (##core#undefined) ) ) )
;;; Display hexdump:
@@ -899,7 +899,7 @@ EOF
(define (fail msg)
(display msg)
(newline)
- (return (##sys#void)))
+ (return (##core#undefined)))
(do ((ct ct (cdr ct)))
((null? ct) (fail "no environment in frame"))
;;XXX this should be refactored as it duplicates the code above
@@ -922,7 +922,7 @@ EOF
(##sys#slot data 2) ; e
(##sys#slot data 3)) ; v
(fail (##sys#string-append "no such variable: " name)))))))
- (##sys#void))))))
+ (##core#undefined))))))
;;; Handle some signals:
@@ -1062,7 +1062,7 @@ EOF
(load cfg-fn))
((and home-fn (file-exists? home-fn))
(load home-fn) ) ) ) )
- (define (evalstring str #!optional (rec (lambda _ (void))))
+ (define (evalstring str #!optional (rec (lambda _ (##core#undefined))))
(let ((in (open-input-string str))
(read-with-source-info chicken.syntax#read-with-source-info)) ; OBSOLETE - after bootstrapping we can get rid of this explicit namespacing
(do ([x (read-with-source-info in) (read-with-source-info in)])
diff --git a/library.scm b/library.scm
index ce761505..449d957d 100644
--- a/library.scm
+++ b/library.scm
@@ -1038,7 +1038,7 @@ EOF
(else #f) ) ) ) )
(define (each . procs)
- (cond ((null? procs) (lambda _ (void)))
+ (cond ((null? procs) (lambda _ (##core#undefined)))
((null? (##sys#slot procs 1)) (##sys#slot procs 0))
(else
(lambda args
@@ -4545,7 +4545,7 @@ EOF
(when (##core#inline "C_port_openp" port direction)
(##sys#setislot port 8 (fxand (##sys#slot port 8) (fxnot direction)))
((##sys#slot (##sys#slot port 2) 4) port direction)
- (##sys#void))))
+ (##core#undefined))))
(set! scheme#open-input-file (lambda (name . mode) (open name #t mode 'open-input-file)))
(set! scheme#open-output-file (lambda (name . mode) (open name #f mode 'open-output-file)))
@@ -5668,7 +5668,7 @@ EOF
(define (##sys#write-char-0 c p)
((##sys#slot (##sys#slot p 2) 2) p c)
- (##sys#void))
+ (##core#undefined))
(define (##sys#write-char/port c port)
(##sys#check-output-port port #t 'write-char)
@@ -5702,15 +5702,13 @@ EOF
(lambda args
(##sys#check-output-port ##sys#standard-output #t 'print)
(*print-each args)
- (##sys#write-char-0 #\newline ##sys#standard-output)
- (void)))
+ (##sys#write-char-0 #\newline ##sys#standard-output)))
(set! chicken.base#print*
(lambda args
(##sys#check-output-port ##sys#standard-output #t 'print)
(*print-each args)
- (##sys#flush-output ##sys#standard-output)
- (void)))
+ (##sys#flush-output ##sys#standard-output)))
(define ##sys#current-print-length (make-parameter 0))
(define ##sys#print-length-limit (make-parameter #f))
@@ -5737,7 +5735,7 @@ EOF
(let ((n (fx- length-limit cpp0)))
(when (fx> n 0) (outstr0 port (##sys#substring str 0 n)))
(outstr0 port "...")
- ((##sys#print-exit) (##sys#void)))
+ ((##sys#print-exit) (##core#undefined)))
(outstr0 port str) )
(##sys#current-print-length cpl) )
(outstr0 port str) ) )
@@ -5752,7 +5750,7 @@ EOF
(##sys#current-print-length (fx+ cpp0 1))
(when (fx> cpp0 length-limit)
(outstr0 port "...")
- ((##sys#print-exit) (##sys#void)))))
+ ((##sys#print-exit) (##core#undefined)))))
((##sys#slot (##sys#slot port 2) 2) port chr)) ; write-char
(define (specialchar? chr)
@@ -5932,7 +5930,7 @@ EOF
(outchr port #\space)
(out (##sys#slot x i)) ) ) ) ) )
(else (##sys#error "unprintable block object encountered")))))
- (##sys#void))))
+ (##core#undefined))))
(define ##sys#procedure->string
(let ((string-append string-append))
@@ -8218,7 +8216,7 @@ static C_word C_curdir(C_word buf, C_word size) {
(when (##core#inline "C_port_openp" port 2)
((##sys#slot (##sys#slot port 2) 4) port 2))
(##sys#setislot port 8 0)
- (##sys#void)))
+ (##core#undefined)))
(set! scheme#call-with-port
(lambda (port proc)
diff --git a/posixunix.scm b/posixunix.scm
index 8e2c5f08..1dadf8b0 100644
--- a/posixunix.scm
+++ b/posixunix.scm
@@ -822,7 +822,7 @@ static int set_file_mtime(C_word filename, C_word atime, C_word mtime)
(eq? e _eagain)))
(define ##sys#custom-input-port
- (lambda (loc nam fd #!optional (nonblocking? #f) (bufi 1) (on-close void) (more? #f) enc)
+ (lambda (loc nam fd #!optional (nonblocking? #f) (bufi 1) (on-close ##sys#void) (more? #f) enc)
(when nonblocking? (##sys#file-nonblocking! fd) )
(let ((bufsiz (if (fixnum? bufi) bufi (##sys#size bufi)))
(buf (if (fixnum? bufi) (##sys#make-bytevector bufi) bufi))
@@ -968,7 +968,7 @@ static int set_file_mtime(C_word filename, C_word atime, C_word mtime)
this-port ) ) ) ) )
(define ##sys#custom-output-port
- (lambda (loc nam fd #!optional (nonblocking? #f) (bufi 0) (on-close void)
+ (lambda (loc nam fd #!optional (nonblocking? #f) (bufi 0) (on-close ##sys#void)
enc)
(when nonblocking? (##sys#file-nonblocking! fd) )
(letrec ((this-port #f)
@@ -1257,7 +1257,7 @@ static int set_file_mtime(C_word filename, C_word atime, C_word mtime)
(vector-set! clsvec idx #t)
(when (and (vector-ref clsvec idxa) (vector-ref clsvec idxb))
(chicken.process#process-wait proc #f) )
- (void)) ))
+ (##core#undefined)) ))
(needed-pipe
(lambda (loc port)
(and port
diff --git a/r7lib.scm b/r7lib.scm
index b6258e0d..6c691d9a 100644
--- a/r7lib.scm
+++ b/r7lib.scm
@@ -56,7 +56,7 @@
(##sys#current-print-length (fx+ pl 1))
(when (fx> pl n)
(emit "..." p)
- ((##sys#print-exit) (##sys#void)))))
+ ((##sys#print-exit) (##core#undefined)))))
((##sys#slot (##sys#slot p 2) 2) p c))) ; write-char
(define (display-string s p)
@@ -69,7 +69,7 @@
(let ((m (fx- n pl2)))
(when (fx> m 0) (emit (##sys#substring s 0 m) p))
(emit "..." p)
- ((##sys#print-exit) (##sys#void)))
+ ((##sys#print-exit) (##core#undefined)))
(emit s p))
(##sys#current-print-length pl2))
(emit s p))))
Trap