From 2c3bd2b04a2b4fff600cd6c430244a8b543ddbd8 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Thu, 28 Apr 2016 11:11:46 +0200 Subject: [PATCH] Change how unbound variables are checked for. To: address@hidden The previous method checks if the object 'x' we want to check is equal to the value contained in the first slot of a symbol that's supposed to always be undefined. This patch replaces the code above with the use of the C_boundp and C_unboundvaluep macros with no functional effect. --- csi.scm | 2 +- eval.scm | 6 +----- extras.scm | 2 +- library.scm | 5 ++--- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/csi.scm b/csi.scm index 5466deb..65ec3fe 100644 --- a/csi.scm +++ b/csi.scm @@ -621,7 +621,7 @@ EOF ((bignum? x) (fprintf out "exact large integer ~S~% #x~X~% #o~O~% #b~B~%" x x x x) ) - ((eq? x (##sys#slot '##sys#arbitrary-unbound-symbol 0)) + ((##core#inline "C_unboundvaluep" x) (fprintf out "unbound value~%") ) ((flonum? x) (fprintf out "inexact rational number ~S~%" x)) ((ratnum? x) (fprintf out "exact ratio ~S~%" x)) diff --git a/eval.scm b/eval.scm index b426d11..c4755c5 100644 --- a/eval.scm +++ b/eval.scm @@ -206,11 +206,7 @@ (define ##sys#eval-debug-level (make-parameter 1)) (define compile-to-closure - (let ([write write] - [reverse reverse] - [with-input-from-file with-input-from-file] - [unbound (##sys#slot '##sys#arbitrary-unbound-symbol 0)] - [display display] ) + (let ((reverse reverse)) (lambda (exp env se #!optional cntr evalenv static) (define (find-id id se) ; ignores macro bindings diff --git a/extras.scm b/extras.scm index 6f0455c..c04f9ef 100644 --- a/extras.scm +++ b/extras.scm @@ -359,7 +359,7 @@ [else (out (make-string 1 obj) col)] ) ) ) ) ((##core#inline "C_undefinedp" obj) (out "#" col)) ((##core#inline "C_anypointerp" obj) (out (##sys#pointer->string obj) col)) - ((eq? obj (##sys#slot '##sys#arbitrary-unbound-symbol 0)) + ((##core#inline "C_unboundvaluep" obj) (out "#" col) ) ((##sys#generic-structure? obj) (let ([o (open-output-string)]) diff --git a/library.scm b/library.scm index e0b3004..292554e 100644 --- a/library.scm +++ b/library.scm @@ -3978,8 +3978,7 @@ EOF [else (outchr port x)] ) ) ] [else (outchr port x)] ) ) ((##core#inline "C_fixnump" x) (outstr port (##sys#number->string x))) - ((eq? x (##sys#slot '##sys#arbitrary-unbound-symbol 0)) - (outstr port "#") ) + ((##core#inline "C_unboundvaluep" x) (outstr port "#")) ((not (##core#inline "C_blockp" x)) (outstr port "#")) ((##core#inline "C_forwardedp" x) (outstr port "#")) ((##core#inline "C_symbolp" x) @@ -5034,7 +5033,7 @@ EOF (##core#inline "C_update_pointer" addr vec) ) (define (##sys#symbol-has-toplevel-binding? s) - (not (eq? (##sys#slot s 0) (##sys#slot '##sys#arbitrary-unbound-symbol 0))) ) + (##core#inline "C_boundp" s)) (define (##sys#copy-bytes from to offset1 offset2 bytes) (##core#inline -- 2.8.0