GNU bug report logs - #58001
Cannot use 'read' in imported library

Previous Next

Package: guile;

Reported by: author <at> will.party

Date: Thu, 22 Sep 2022 08:06:01 UTC

Severity: normal

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: author <at> will.party
To: bug-guile <at> gnu.org
Subject: Cannot use 'read' in imported library
Date: Thu, 22 Sep 2022 00:30:40 -0700
[Message part 1 (text/plain, inline)]
I'm using Guile version 3.0.5 from the Guix repository.

I've run into a strange issue with the read function from (scheme 
base). It cannot be used in an R7RS-style library. This only seems to 
apply to the read function. Other standard procedures work fine.

Let's say you have a library that uses read. Maybe it looks like this:

;; File: foo.scm
(define-library (foo)
 (import (scheme base))
 (export read-wrapped)
 (begin
   (define (read-wrapped port) (read port))))

Now, let's say you want to import that library somewhere else and use 
it's exported function read-wrapped:

;; File: main.scm
(import (scheme base))
(import (foo))
(display (read (current-input-port)))
(display (read-wrapped (current-input-port)))

If you try to run that main script (in the same directory as the foo 
library):

GUILE_LOAD_PATH=. guile --r7rs main.scm

You can enter get a datum for the first call to read, then you'll get 
an error for the second call:

foo.scm:1:0: In procedure read-wrapped:
Unbound variable: read

This only happens with read. If you replace read with a different 
standard procedure like boolean? then everything is fine (you'll see #f 
twice because the input port fails the predicate).

I'm pretty baffled. I've attached the dummy source files for 
convenience.

[Message part 2 (text/html, inline)]
[foo.scm (text/x-scheme, attachment)]
[main.scm (text/x-scheme, attachment)]

This bug report was last modified 2 years and 332 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.