[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 16:57:45 +0200 (MEST) |
On Wed, 18 Jul 2001, Wayne Scott wrote:
>
> You can include a module into the toplevel Construct script and have
> it available to all the subscripts. You just need to select the
> destination package explicitly.
>
> For example my Construct file looks like this:
>
> BEGIN {
> package cons;
> use Mystuff;
> }
> $CONS = new cons;
>
> $CONS->printhi; # call new method
>
> Mystuff.pm looks like this:
>
> package Mystuff;
>
> require Exporter;
> @ISA = qw(Exporter);
> @EXPORT = qw(printhi);
>
> sub printhi
> {
> print "hello\n";
> }
>
> 1;
>
Isn't this just a complicated way of doing, what could easier be
written like this:
Construct file:
use Mystuff;
$CONS = new cons;
$CONS->printhi; # call new method
Mystuff.pm:
package Mystuff;
sub cons::printhi
{
print "hello\n";
}
1;
This was one of the alternatives that Jeff Rosenfeld mentioned in
his reply earlier:
> 2. Your package can define methods in the "cons" package so that
> Conscripts can invoke them just like other cons methods.
I see no reason to "pollute" the Construct file with constructs
like:
> BEGIN {
> package cons;
> use Mystuff;
> }
Isn't it better to let "Mystuff.pm" place the function where it
likes to (in this case in the "cons" package) ?
/johan
- 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, 2001/07/18
- 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 <=
- RE: Packages and cons, Gary Oberbrunner, 2001/07/18