[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: access of global variables from modules
From: |
Neil Jerram |
Subject: |
Re: access of global variables from modules |
Date: |
01 Apr 2002 15:26:06 +0100 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 |
>>>>> "Peter" == Peter Ivanyi <address@hidden> 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
- Re: access of global variables from modules,
Neil Jerram <=