From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Pirotte Newsgroups: gmane.lisp.guile.user Subject: Re: Module reflection and the list of bound symbols Date: Sun, 30 Sep 2012 13:21:06 -0300 Message-ID: <20120930132106.49c5edac@capac> References: <87ehljr6ie.fsf@googlemail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/RJUbmGXEy38TnyP77B5jDfv" X-Trace: ger.gmane.org 1349022115 20446 80.91.229.3 (30 Sep 2012 16:21:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 30 Sep 2012 16:21:55 +0000 (UTC) Cc: guile-user@gnu.org To: Ian Price Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Sep 30 18:22:01 2012 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TIMHI-0005n0-CW for guile-user@m.gmane.org; Sun, 30 Sep 2012 18:22:00 +0200 Original-Received: from localhost ([::1]:35045 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TIMHC-0003dE-VA for guile-user@m.gmane.org; Sun, 30 Sep 2012 12:21:54 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:52188) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TIMH8-0003d9-8u for guile-user@gnu.org; Sun, 30 Sep 2012 12:21:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TIMH7-00021Q-1m for guile-user@gnu.org; Sun, 30 Sep 2012 12:21:50 -0400 Original-Received: from maximusconfessor.all2all.org ([62.58.108.13]:51164) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TIMH6-0001zD-RX for guile-user@gnu.org; Sun, 30 Sep 2012 12:21:48 -0400 Original-Received: from localhost (unknown [192.168.0.2]) by maximusconfessor.all2all.org (Postfix) with ESMTP id 659E5A04C0C7; Sun, 30 Sep 2012 18:21:26 +0200 (CEST) Original-Received: from maximusconfessor.all2all.org ([192.168.0.1]) by localhost (maximusconfessor.all2all.org [192.168.0.2]) (amavisd-new, port 10024) with ESMTP id L4H-nk6fINnW; Sun, 30 Sep 2012 17:53:39 +0200 (CEST) Original-Received: from capac (unknown [177.149.255.181]) by maximusconfessor.all2all.org (Postfix) with ESMTPSA id 33DE0A04C0C3; Sun, 30 Sep 2012 18:21:10 +0200 (CEST) In-Reply-To: <87ehljr6ie.fsf@googlemail.com> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 62.58.108.13 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:9600 Archived-At: --MP_/RJUbmGXEy38TnyP77B5jDfv Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello, > ... to get only the public (exported) ones using the > interfaces, but that is beyond my knowledge at the moment. Here is what i do, see the attached code [which i copied from guile-gnome], then you can use it this way, as an example: 1. you define a module b and export some ... 2. ;;; file a.scm STARTS here (define-module (a) :use-module (reexport) :use-module (b)) :export ... ... (eval-when (compile load eval) (re-export-public-interface (b))) ;; your code here... ;; ... ;;; file a.scm ENDS here 3. finally: guile scheme@(guile-user)> (use-modules (a)) ;; then you can use both public interface from a and b Of course this is true for any module which uses the module a [it can refers to the public interface of b too...] Hope this helps, Cheers, David ps: i have always tought guile itself should provide this feature as built-in --MP_/RJUbmGXEy38TnyP77B5jDfv Content-Type: text/x-scheme Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=reexport.scm ;; -*- mode: scheme; coding: utf-8 -*- ;;;; Copyright (C) 2011, 2012 ;;;; Free Software Foundation, Inc. ;;;; This library is free software: you can redistribute it and/or ;;;; modify it under the terms of the GNU General Public License as ;;;; published by the Free Software Foundation, either version 3 of ;;;; the License, or (at your option) any later version. ;;;; This library is distributed in the hope that it will be useful, but ;;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;;; General Public License for more details. ;;;; You should have received a copy of the GNU General Public License ;;;; along with this library. If not, see . ;;;; ;;; Commentary: ;; this code is the same as the one use by guile-gnome, see ;; /usr/local/share/guile-gnome-2/gnome/gw/support/modules.scm ;;; Code: (define-module (macros reexport) :export (re-export-public-interface)) (define-macro (re-export-public-interface . args) "Re-export the public interface of a module or modules. Invoked as @code{(re-export-modules (mod1) (mod2)...)}." (if (null? args) '(if #f #f) `(begin ,@(map (lambda (mod) (or (list? mod) (error "Invalid module specification" mod)) `(module-use! (module-public-interface (current-module)) (resolve-interface ',mod))) args)))) --MP_/RJUbmGXEy38TnyP77B5jDfv--