From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: author@will.party Newsgroups: gmane.lisp.guile.bugs Subject: bug#58001: Cannot use 'read' in imported library Date: Thu, 22 Sep 2022 00:30:40 -0700 Message-ID: <4VOLIR.1V2A6YW618L42@will.party> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-UkZTPNEx7HhUx7tcNAW8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22584"; mail-complaints-to="usenet@ciao.gmane.io" To: 58001@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Thu Sep 22 10:07:24 2022 Return-path: Envelope-to: guile-bugs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1obHEr-0005K7-MF for guile-bugs@m.gmane-mx.org; Thu, 22 Sep 2022 10:07:17 +0200 Original-Received: from localhost ([::1]:41296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1obHEq-0004kw-O0 for guile-bugs@m.gmane-mx.org; Thu, 22 Sep 2022 04:07:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35148) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1obHDe-0004he-FE for bug-guile@gnu.org; Thu, 22 Sep 2022 04:06:09 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37078) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1obHDe-0001Rr-5Z for bug-guile@gnu.org; Thu, 22 Sep 2022 04:06:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1obHDd-0003nY-W9 for bug-guile@gnu.org; Thu, 22 Sep 2022 04:06:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: author@will.party Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Thu, 22 Sep 2022 08:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 58001 X-GNU-PR-Package: guile X-Debbugs-Original-To: bug-guile@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.166383390514504 (code B ref -1); Thu, 22 Sep 2022 08:06:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 22 Sep 2022 08:05:05 +0000 Original-Received: from localhost ([127.0.0.1]:36151 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1obHCi-0003lr-H5 for submit@debbugs.gnu.org; Thu, 22 Sep 2022 04:05:05 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:59096) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1obGfp-0002uL-VS for submit@debbugs.gnu.org; Thu, 22 Sep 2022 03:31:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1obGfp-0000SG-Ci for bug-guile@gnu.org; Thu, 22 Sep 2022 03:31:05 -0400 Original-Received: from mout-p-101.mailbox.org ([2001:67c:2050:0:465::101]:33834) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1obGfk-0003CP-Ua for bug-guile@gnu.org; Thu, 22 Sep 2022 03:31:05 -0400 Original-Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4MY6QL6lq6z9sc6 for ; Thu, 22 Sep 2022 09:30:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=will.party; s=MBO0001; t=1663831851; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=EKalomiv6kMV/ppgUU1VeHVxXjs9kpLBEaMFhoCrSaQ=; b=yySwUrP8x0nhdYeoaNLVMWE/uxYZ8jhLChMhOzmJQCUt/xfoCNKk85sJOMYtvwS2bzek7h toMexq9tUHPIRji3CWlmd83pVA0Li7XPLEhUo171acAc+yY69PVxEiAV5T2+MkFIRC4P60 oOjYdbEWqJRz7G2kMfUc6mhH58ZxJ7yjeJ/a3g52wR2qrJEYPUWb76vhLK8AuwS/ZrySBO jSV4qOQ25zQn7NBgVQiVrbkEhOQR518EGKSuQ3VmiZkinpiPOx3dXVKaSpm89VzIo3o7i7 KWpoR20txxBHMDpubjMyZ2g2KXKBuPOLZoS0KDsGINWJFAIq4eiPsYeNyzYcCA== Received-SPF: none client-ip=2001:67c:2050:0:465::101; envelope-from=author@will.party; helo=mout-p-101.mailbox.org X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 22 Sep 2022 04:05:03 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.io gmane.lisp.guile.bugs:10376 Archived-At: --=-UkZTPNEx7HhUx7tcNAW8 Content-Type: multipart/alternative; boundary="=-8HJF6unqtXxgtH90Z1fP" --=-8HJF6unqtXxgtH90Z1fP Content-Type: text/plain; charset=us-ascii; format=flowed 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. --=-8HJF6unqtXxgtH90Z1fP Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: quoted-printable
I'm using Guile version 3.0.5 from= the Guix repository.

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

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

;; File: foo.scm
(define-library (foo)
&nbs= p; (import (scheme base))
  = (export read-wrapped)
  (beg= in
    (define (read-wr= apped port) (read port))))

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

<= div>;; File: main.scm
(import (scheme base))
(import (foo))
(display = (read (current-input-port)))
(dis= play (read-wrapped (current-input-port)))

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

GUILE_LOAD_PATH=3D. guile -= -r7rs main.scm

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

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

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

I'm pretty baffled. I've attach= ed the dummy source files for convenience.
--=-8HJF6unqtXxgtH90Z1fP-- --=-UkZTPNEx7HhUx7tcNAW8 Content-Type: multipart/mixed; boundary="=-gYlU/vh2KmkZuje5CdgM" --=-gYlU/vh2KmkZuje5CdgM Content-Type: text/x-scheme Content-Disposition: attachment; filename=foo.scm Content-Transfer-Encoding: base64 KGRlZmluZS1saWJyYXJ5IChmb28pCiAgKGltcG9ydCAoc2NoZW1lIGJhc2UpKQogIChleHBvcnQg cmVhZC13cmFwcGVkKQogIChiZWdpbgogICAgKGRlZmluZSAocmVhZC13cmFwcGVkIHBvcnQpIChy ZWFkIHBvcnQpKSkpCg== --=-gYlU/vh2KmkZuje5CdgM Content-Type: text/x-scheme Content-Disposition: attachment; filename=main.scm Content-Transfer-Encoding: base64 KGltcG9ydCAoc2NoZW1lIGJhc2UpKQooaW1wb3J0IChmb28pKQoKKGRpc3BsYXkgKHJlYWQgKGN1 cnJlbnQtaW5wdXQtcG9ydCkpKQooZGlzcGxheSAocmVhZC13cmFwcGVkIChjdXJyZW50LWlucHV0 LXBvcnQpKSkK --=-gYlU/vh2KmkZuje5CdgM-- --=-UkZTPNEx7HhUx7tcNAW8--