[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: confinement's read-hash-extend gives 'unknown number radix' for all
From: |
Ludovic Courtès |
Subject: |
Re: confinement's read-hash-extend gives 'unknown number radix' for all tagged forms |
Date: |
Wed, 21 Oct 2020 22:43:57 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
Hi Jelle,
Jelle Licht <jlicht@fsfe.org> skribis:
> The following does not:
>
> (use-modules (system reader confinement)
> (language elisp parser))
> (read-hash-extend #\e (lambda (_ port) (read-elisp port)))
> (format #t "~S\n" #e(+ 1 1))
>
> ; ERROR: In procedure apply-smob/3:
> ; In procedure scm_read_number_and_radix: /tmp/confined.scm:3:20: unknown
> number radix
It seems that the problem is that Guile-Reader’s ‘read-hash-extend’
appends hash extensions, whereas Guile’s prepends them. See
confinement.scm:
(set! sharp-specs
;; Append the module's hash extensions. Warning: no attempt is
;; made to avoid conflicts.
(append (map (lambda (chr+proc)
(make-token-reader (car chr+proc)
(lambda (chr port read top)
(apply (cdr chr+proc)
(list chr port)))))
(ensure-reader-hash-extensions module))
sharp-specs))
Consequently, the default behavior for #e kicks in, and that invokes the
“token reader” for numbers.
We could change the code above to prepend.
HTH!
Ludo’.
- Re: confinement's read-hash-extend gives 'unknown number radix' for all tagged forms,
Ludovic Courtès <=