From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Neil Jerram Newsgroups: gmane.lisp.guile.user Subject: Re: access of global variables from modules Date: 01 Apr 2002 15:26:06 +0100 Sender: guile-user-admin@gnu.org Message-ID: References: <3CA63FA1.5FBAC15@carme.sect.mce.hw.ac.uk> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1017673254 9755 127.0.0.1 (1 Apr 2002 15:00:54 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 1 Apr 2002 15:00:54 +0000 (UTC) Cc: "guile-user@gnu.org" Original-Received: from fencepost.gnu.org ([199.232.76.164]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 16s3Ij-0002XE-00 for ; Mon, 01 Apr 2002 17:00:53 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 16s3C9-0002lL-00; Mon, 01 Apr 2002 09:54:05 -0500 Original-Received: from mail.uklinux.net ([80.84.72.21] helo=s1.uklinux.net) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 16s2p5-000680-00 for ; Mon, 01 Apr 2002 09:30:15 -0500 Original-Received: from portalet.ossau.uklinux.net (IDENT:root@ppp-3a-37.3com.telinco.net [212.159.132.37]) by s1.uklinux.net (8.11.6/8.11.6) with ESMTP id g31EU7718323; Mon, 1 Apr 2002 15:30:08 +0100 Original-Received: from laruns.ossau.uklinux.net.ossau.uklinux.net (neil@laruns.ossau.uklinux.net [192.168.1.3]) by portalet.ossau.uklinux.net (8.9.3/8.8.7) with ESMTP id PAA09765; Mon, 1 Apr 2002 15:29:28 +0100 Original-To: "Mr. Peter Ivanyi" Original-Lines: 42 User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 Errors-To: guile-user-admin@gnu.org X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.0.8 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.lisp.guile.user:95 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:95 >>>>> "Peter" == Peter Ivanyi writes: Peter> Hello again, Peter> I have another problem with modules. Peter> If I have a module can the module access "global" variables. Peter> I have an application, which defines some global variables. Peter> The application also loads some modules and I would like to access Peter> the global variables from the module. Peter> How can I do it ? (I think I can put the global variables into a module Peter> and another module can depend on it, but isn't there another way ?) Peter> For example I have this module (gen.scm): Peter> ---------------------- Peter> (define-module (gen gen)) Peter> (export gen-hello) Peter> (define (gen-hello) Peter> (set! *G* 3) Peter> (display "Hello World !") Peter> (newline) Peter> ) Peter> ------------------------- What exactly do you mean by a global variable? Every variable must be defined in some module, and in this case what you need to do is: - export *G* from the module in which it is defined - in (gen gen), `use' that module. If you say that *G* is global, you probably mean that it is defined in the (guile-user) module. So what you need is: ;; ... just after the definition of *G* ... (export *G*) ;; In gen.scm after the define-module line ... (use-modules (guile-user)) Please let me know if this helps. Neil _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://mail.gnu.org/mailman/listinfo/guile-user