From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Leo Prikler Newsgroups: gmane.lisp.guile.bugs Subject: bug#43025: re-export-public-interface fails on Guile 3 Date: Mon, 24 Aug 2020 21:50:32 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2234"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.34.2 To: dalepsmith@gmail.com, 43025@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Mon Aug 24 21:51:09 2020 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 1kAIUn-0000SX-Dh for guile-bugs@m.gmane-mx.org; Mon, 24 Aug 2020 21:51:09 +0200 Original-Received: from localhost ([::1]:54396 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kAIUm-0008QC-D0 for guile-bugs@m.gmane-mx.org; Mon, 24 Aug 2020 15:51:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kAIUg-0008Ov-2Y for bug-guile@gnu.org; Mon, 24 Aug 2020 15:51:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47818) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kAIUf-0002HA-PE for bug-guile@gnu.org; Mon, 24 Aug 2020 15:51:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kAIUf-0000EQ-NS for bug-guile@gnu.org; Mon, 24 Aug 2020 15:51:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Leo Prikler Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Mon, 24 Aug 2020 19:51:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43025 X-GNU-PR-Package: guile X-Debbugs-Original-To: Dale Smith , bug-guile@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.1598298651865 (code B ref -1); Mon, 24 Aug 2020 19:51:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 24 Aug 2020 19:50:51 +0000 Original-Received: from localhost ([127.0.0.1]:59364 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kAIUU-0000Dq-Em for submit@debbugs.gnu.org; Mon, 24 Aug 2020 15:50:50 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:33544) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kAIUS-0000Dg-2C for submit@debbugs.gnu.org; Mon, 24 Aug 2020 15:50:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49792) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kAIUR-0008CU-Pr for bug-guile@gnu.org; Mon, 24 Aug 2020 15:50:47 -0400 Original-Received: from mailrelay.tugraz.at ([129.27.2.202]:39709) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kAIUN-00025l-9u for bug-guile@gnu.org; Mon, 24 Aug 2020 15:50:46 -0400 Original-Received: from nijino.local (213-147-177-210.hdsl.highway.telekom.at [213.147.177.210]) by mailrelay.tugraz.at (Postfix) with ESMTPSA id 4Bb2mB3Cbyz1LWpP; Mon, 24 Aug 2020 21:50:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 mailrelay.tugraz.at 4Bb2mB3Cbyz1LWpP DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tugraz.at; s=mailrelay; t=1598298634; bh=VkEe+Ot5vCUELy95/b3tq3Y6xnzzrOfWYMhL9U8EK74=; h=Subject:From:To:Date:In-Reply-To:References:From; b=odmIxIV1mtujGK1uPbkEufm6OY1JhcF7rCnljfLcdSeM6gzQ5fgehQbqA5JUrG+/Y X9GqfIHKn+LUmYop2oziz7V/4e39y862KfPQF3OYwG5DEc2qCqr5aQrzh8Kmya0YIq qlBA7o5p/LtUUAEvUqyErb7XF2ERcWYrrCGjRSD4= In-Reply-To: X-TUG-Backscatter-control: bt4lQm5Tva3SBgCuw0EnZw X-Scanned-By: MIMEDefang 2.74 on 129.27.10.117 Received-SPF: pass client-ip=129.27.2.202; envelope-from=leo.prikler@student.tugraz.at; helo=mailrelay.tugraz.at X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/24 15:50:36 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:9867 Archived-At: Hi Dale. Am Montag, den 24.08.2020, 12:11 -0400 schrieb Dale Smith: > This is actually reported by daviid on IRC. > > This definition of re-export-public-interface works fine on Guile > 2.x, > fails with Guile 3: > (hope this makes it through the mails cleanly) > ;;; > ;;; re-export-public-interface > ;;; > > [...] I'm going to skip the specifics of the macro here, it is not needed for an MWE. > ;;; > ;;; A module that uses the above > ;;; > > > (define-module (a) > #:use-module (srfi srfi-1) > #:use-module (modules) > > #:export (map-a)) > > > (eval-when (expand load eval) > (re-export-public-interface (srfi srfi-1))) > > > (define (map-a) > (map (lambda (item) > (display item) > (display " ")) > (iota 5)) > (newline) > (values)) > For the sake of minimalism, I will shorten this to (define-module (a)) (module-use! (module-public-interface (current-module)) (resolve-interface '(srfi srfi-1))) I hope you don't mind. > [sessions] My solution for this problem would be to build on some of the module "intrinsics", which sadly are not all that well documented. (define-module (a)) (let ((obs (module-obarray (resolve-interface '(srfi srfi-1)))) (iface (module-public-interface (current-module)))) (hash-fold (lambda (key value seed) (module-add! iface key value) seed) *unspecified* obs)) If you want to make this a macro, you really only need to syntax- unquote a module into the (resolve-interface ...) portion of this snippet. Some sessions for reference: GNU Guile 3.0.4 Copyright (C) 1995-2020 Free Software Foundation, Inc. Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'. This program is free software, and you are welcome to redistribute it under certain conditions; type `,show c' for details. Enter `,help' for help. scheme@(guile-user)> (add-to-load-path "/tmp") scheme@(guile-user)> ,use (a) ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0 ;;; or pass the --no-auto-compile argument to disable. ;;; compiling /tmp/a.scm ;;; compiled $HOME/.cache/guile/ccache/3.0-LE-8-4.3/tmp/a.scm.go scheme@(guile-user)> map WARNING: (guile-user): imported module (a) overrides core binding `map' $1 = # scheme@(guile-user)> ,q GNU Guile 3.0.2 Copyright (C) 1995-2020 Free Software Foundation, Inc. Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'. This program is free software, and you are welcome to redistribute it under certain conditions; type `,show c' for details. Enter `,help' for help. scheme@(guile-user)> (add-to-load-path "/tmp") scheme@(guile-user)> ,use (a) ;;; note: source file /tmp/a.scm ;;; newer than compiled /home/yuri/.cache/guile/ccache/3.0-LE-8- 4.2/tmp/a.scm.go ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0 ;;; or pass the --no-auto-compile argument to disable. ;;; compiling /tmp/a.scm ;;; compiled $HOME/.cache/guile/ccache/3.0-LE-8-4.2/tmp/a.scm.go scheme@(guile-user)> map WARNING: (guile-user): imported module (a) overrides core binding `map' $1 = # scheme@(guile-user)> ,q GNU Guile 2.2.7 Copyright (C) 1995-2019 Free Software Foundation, Inc. Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'. This program is free software, and you are welcome to redistribute it under certain conditions; type `,show c' for details. Enter `,help' for help. scheme@(guile-user)> (add-to-load-path "/tmp") scheme@(guile-user)> ,use (a) ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0 ;;; or pass the --no-auto-compile argument to disable. ;;; compiling /tmp/a.scm ;;; compiled $HOME/.cache/guile/ccache/2.2-LE-8-3.A/tmp/a.scm.go scheme@(guile-user)> map $1 = # scheme@(guile-user)> ,q Interestingly, versions newer than 3.0.2 warn about core override in this case, as does #:re-export. If I am not mistaken, this is the way re-export works for variables normally. module-use! on the other hand does not modify the module-obarray, it instead adds the module to a list of uses, which are handled separately in variable lookup during `module_imported_variable`. This C function does look up variables exported by a module, but does not traverse module-uses recursively. I have no idea, how this works for 2.2.7, I only checked the Guile 3 code here. Regards, Leo