On 3/29/07, minh thu <[EMAIL PROTECTED]> wrote:
Hi,
Say I've a module with a bunch of procedures that use a global variable.
Call it *global*.
Can I use that module and specify that *global* is an alias of *my-global* ?
(So that every procedures of the above module now work actually on *my-global*.)
It might be cleaner to use parameters instead:
(define *global* (make-parameter #f))
;; set the value:
(*global* *my-global*) ; or whatever
;; use the value
(print (+ 3 (*global*)))
If you're not familiar with parameters, it's worth a quick read of the
docs (in short, they give you dynamic scoping instead of lexical
scoping).
If you're going to the bother of rewriting all your *global*
references to (*global*) instead, I suppose you could cheat and use
(define-macro (*global*) '*my-global*) instead. But I'd use
parameters.
Graham
_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users