Skip to content

Instantly share code, notes, and snippets.

@yamasushi
Last active April 6, 2018 08:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yamasushi/5519247 to your computer and use it in GitHub Desktop.
Save yamasushi/5519247 to your computer and use it in GitHub Desktop.
;; replからではなく、直接repl-printを使ったときに起きる。
;; Shiro Kawai's xrepl.pp (pp.scm line 70 ~ 86)
;; SourceForge.net Repository - [gauche] Contents of /Gauche-scripts/trunk/xrepl/xrepl/pp.scm
;; http://gauche.svn.sourceforge.net/viewvc/gauche/Gauche-scripts/trunk/xrepl/xrepl/pp.scm?revision=7388&view=markup
;; scan obj to find out shared structure and mark it in rp-dict.
(define (scan-shared obj level len)
#?=(rp-dict) ; <--- ok
(cond [(hash-table-get #?=(rp-dict) obj #f) ; <---- ok
=> (lambda (n)
(unless (number? n)
(hash-table-put! (rp-dict) obj
(rlet1 n (rp-count) (rp-count (+ n 1))))))]
[(or (> level *rp-level*) (> len *rp-length*) (simple-obj? obj))]
[else
(hash-table-put! #?=(rp-dict) obj #t) ; <---- !!! (rp-dict)==#f
(cond [(pair? obj)
(scan-shared (car obj) (+ level 1) 0)
(scan-shared (cdr obj) level (+ len 1))]
[(vector? obj)
(do-ec (: i (min (vector-length obj) *rp-length*))
(scan-shared (vector-ref obj i) (+ level 1) 0))])]))
;;
#?="/home/shuji/gauche/xrepl/pp.scm":72:(rp-dict)
#?- #<hash-table eq? 0x9f17528>
#?="/home/shuji/gauche/xrepl/pp.scm":73:(rp-dict)
#?- #<hash-table eq? 0x9f17528>
#?="/home/shuji/gauche/xrepl/pp.scm":80:(rp-dict)
#?- #f <------????
*** ERROR: hash table required, but got #f
Stack Trace:
_______________________________________
0 (hash-table-put! (debug-print (rp-dict)) obj #t)
At line 80 of "/home/shuji/gauche/xrepl/pp.scm"
1 (scan-shared obj 0 0)
At line 234 of "/home/shuji/gauche/xrepl/pp.scm"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment