From: Andy
Subject: Newbie question: Variable with package scope ?
Date:
Message-ID: <3CE3BEC4.AFAF3BB9@smi.de>
Hi all,
i wonder if it is possible to create a variable with the
scope of a package that can hold global values that are
used in the package but is not available outside the package
(and so doesn't produce nameconflicts outside the package).
Best
AHz
Andy <···@smi.de> writes:
> Hi all,
> i wonder if it is possible to create a variable with the
> scope of a package that can hold global values that are
> used in the package but is not available outside the package
> (and so doesn't produce nameconflicts outside the package).
>
In in file my-pkg.lisp
(defpackage "MY-PACKAGE"
(:export "ONE" "TWO" "THREE"))
In file zut.lisp
(in-package "MY-PACKAGE")
(defvar *my-global-var* 42)
In file zot.lisp
(in-package "ANOTHER-PACKAGE")
(use-package "MY-PACKAGE")
(defvar *my-global-var* 666)
At this point you have no conflicts and the two variables hold
different values.
Cheers
--
Marco Antoniotti ========================================================
NYU Courant Bioinformatics Group tel. +1 - 212 - 998 3488
719 Broadway 12th Floor fax +1 - 212 - 995 4122
New York, NY 10003, USA http://bioinformatics.cat.nyu.edu
"Hello New York! We'll do what we can!"
Bill Murray in `Ghostbusters'.
"Andy" <···@smi.de> wrote in message ······················@smi.de...
> Hi all,
> i wonder if it is possible to create a variable with the
> scope of a package that can hold global values that are
> used in the package but is not available outside the package
> (and so doesn't produce nameconflicts outside the package).
Packages are mappings from strings to symbols, so the
expression `variable with the scope of a package' doesn't make
sense to me.
Nameconflicts only arise when you import or export symbols
or change which packages are `used' by other packages.
Assigning a value to a variable is not one of these.
From: Andy
Subject: Re: Newbie question: Variable with package scope ?
Date:
Message-ID: <3CE4E2C0.70282B72@smi.de>
Joe Marshall wrote:
>
> Nameconflicts only arise when you import or export symbols
> or change which packages are `used' by other packages.
> Assigning a value to a variable is not one of these.
So, since variables are even symbols they need to be exported from
the package. OK, i thought that only holds for functions.
Thanks for the advice.
Best regards
AHz