On Wed, May 20, 2020 at 08:45:51PM +0200, Peter Bex wrote: > Regarding patch 0002, it looks like we forgot to change > define-record-printer (perhaps because it, itself is deprecated) > to use set-record-printer! instead of ##sys#register-record-printer, > which means we can't remove that definition just yet.
And here's one more patch, because I just realised that CHICKEN wouldn't compile because it's using that define-record-printer macro internally. The patch replaces our internal uses of define-record-printer with set-record-printer! More interestingly, it seems that define-record-printer either doesn't even work, or we're using it wrong somehow: #;1> (import chicken.irregex) ; loading /home/sjamaan/chickens/chicken-5/lib/chicken/11/chicken.irregex.import.so ... #;2> (irregex-match "foo" "foo") #<regexp-match> #;3> (interaction-environment) #<environment> With patch: #;1> (import chicken.irregex) ; loading /home/sjamaan/chickens/test-5/lib/chicken/11/chicken.irregex.import.so ... #;2> (irregex-match "foo" "foo") #<regexp-match (0 submatches)> #;3> (interaction-environment) #<environment interaction-environment> No clue why this doesn't work. I checked, in CHICKEN 4 this worked, so I think we broke this somewhere during our massive CHICKEN 5 changes. I'm not sure it's worth fixing this, considering define-record-printer is obsolete anyway. Presumably nobody is using it, or this would've been reported already? Cheers, Peter
From 4bc24df4ba1a0607d2215a863da87129526ec70a Mon Sep 17 00:00:00 2001 From: Peter Bex <[email protected]> Date: Thu, 21 May 2020 12:40:12 +0200 Subject: [PATCH 3/3] Use set-record-printer! instead of define-record-printer internally define-record-printer is deprecated and apparently doesn't even work correctly(?!) --- eval.scm | 9 +++++---- irregex-core.scm | 15 ++++++++------- misc/chicken.el | 5 +++-- support.scm | 5 +++-- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/eval.scm b/eval.scm index 7c9da9a0..344660dd 100644 --- a/eval.scm +++ b/eval.scm @@ -819,10 +819,11 @@ (let ((e (##sys#make-structure 'environment 'interaction-environment #f #f))) (lambda () e))) -(define-record-printer (environment e p) - (##sys#print "#<environment " #f p) - (##sys#print (##sys#slot e 1) #f p) - (##sys#write-char-0 #\> p)) +(set-record-printer! 'environment + (lambda (e p) + (##sys#print "#<environment " #f p) + (##sys#print (##sys#slot e 1) #f p) + (##sys#write-char-0 #\> p))) (let* ((r4s (chicken.module#module-environment 'r4rs 'scheme-report-environment/4)) (r5s (chicken.module#module-environment 'scheme 'scheme-report-environment/5)) diff --git a/irregex-core.scm b/irregex-core.scm index 9bcf7e0b..ece802a2 100644 --- a/irregex-core.scm +++ b/irregex-core.scm @@ -148,13 +148,14 @@ (##sys#slot (##sys#slot m 1) (+ 3 (* n 4)))) (define (%irregex-match-fail m) (##sys#slot m 4)) (define (%irregex-match-fail-set! m x) (##sys#setslot m 4 x)) - (define-record-printer (regexp-match m out) - (let ((n (irregex-match-num-submatches m))) - (display "#<regexp-match (" out) - (display n out) - (display " submatch" out) - (when (or (eq? n 0) (fx> n 1)) (display "es" out)) - (display ")>" out))) + (set-record-printer! 'regexp-match + (lambda (m out) + (let ((n (irregex-match-num-submatches m))) + (display "#<regexp-match (" out) + (display n out) + (display " submatch" out) + (when (or (eq? n 0) (fx> n 1)) (display "es" out)) + (display ")>" out)))) (define-inline (irregex-match-valid-numeric-index? m n) (let ((v (##sys#slot m 1))) (and (>= n 0) (< (* n 4) (- (##sys#size v) 4))))) diff --git a/misc/chicken.el b/misc/chicken.el index 2874b775..2c31f722 100644 --- a/misc/chicken.el +++ b/misc/chicken.el @@ -165,12 +165,13 @@ (select 1) (functor 3) (define-interface 1) - (module 2) ) ) + (module 2)) ) (setq chicken-indent-list '((printf 1) (fprintf 2) - (sprintf 1))) + (sprintf 1) + (set-record-printer! 1))) ;(put 'module 'scheme-indent-function 'chicken-module-indent) ;(defun chicken-module-indent (state indent-point normal-indent) 0) diff --git a/support.scm b/support.scm index 0027344f..5eff6e23 100644 --- a/support.scm +++ b/support.scm @@ -472,8 +472,9 @@ (parameters node-parameters node-parameters-set!) ; (value...) (subexpressions node-subexpressions node-subexpressions-set!)) ; (node...) -(define-record-printer (node n out) - (fprintf out "#<node ~a ~a>" (node-class n) (node-parameters n))) +(set-record-printer! node + (lambda (n out) + (fprintf out "#<node ~a ~a>" (node-class n) (node-parameters n)))) (define (make-node c p s) (##sys#make-structure 'chicken.compiler.support#node c p s)) -- 2.20.1
signature.asc
Description: PGP signature
