[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Packages and cons
From: |
Johan Holmberg |
Subject: |
Re: Packages and cons |
Date: |
Wed, 18 Jul 2001 12:54:10 +0200 (MEST) |
On Wed, 18 Jul 2001, Frank Thomas wrote:
>
> I would just call "use Cons-subs;" or something similar because this
> would not load it again every time but just import the symbols into your
> namespace.
>
I also think this is the right way to go.
Write your "cons_subs.pm" file something like:
#----------------------------------------------------------------------
package cons_subs;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(cons_subs_fun $cons_subs_scalar);
$cons_subs_scalar = "123";
sub cons_subs_fun
{
# ....
}
1;
#----------------------------------------------------------------------
and add a line:
use cons_subs;
to every "Construct/Conscript" that needs your module.
I think it is a *good thing* that you explicitly declare what your
Conscript files depends on. As I understand it, one of the original
goals of the Cons design was to avoid the mess you get in when using
"global variables" in an uncontrolled way across different files.
Variables/functions should be shared in a controlled way, and since
"use" is the normal way to do it in Perl, I think it should be used
in Conscript files too.
As far as I know, the current handling of "Construct/Conscript" in
Cons (where the files are evaluated in the "script" package, and
the package is cleared after every Construct/Conscript file read)
works well together with Perls "use" mechanism.
/Johan Holmberg
- Packages and cons, Gary Oberbrunner, 2001/07/17
- RE: Packages and cons, Jeff Rosenfeld, 2001/07/17
- RE: Packages and cons, Gary Oberbrunner, 2001/07/17
- RE: Packages and cons, Gary Oberbrunner, 2001/07/17
- Re: Packages and cons, Frank Thomas, 2001/07/18
- Re: Packages and cons,
Johan Holmberg <=
- Re: Packages and cons, Frank Thomas, 2001/07/18
- Re: Packages and cons, Johan Holmberg, 2001/07/18
- Re: Packages and cons, Frank Thomas, 2001/07/18
- Re: Packages and cons, Wayne Scott, 2001/07/18
- Re: Packages and cons, Johan Holmberg, 2001/07/18
- RE: Packages and cons, Gary Oberbrunner, 2001/07/18