cons-discuss
[Top][All Lists]
Advanced

[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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]