cons-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Packages and cons


From: Jeff Rosenfeld
Subject: RE: Packages and cons
Date: Tue, 17 Jul 2001 13:30:25 -0700

Last I knew, cons evaluated all Conscript files in their own packages
(an effort to keep the namespaces clean). Your best bets for extending
cons with your new package are:

1. Construct file uses or requires cons-subs. Cons-subs can either
create subroutines in its own package (it's unfriendly to define them in
main) so that Conscripts can call ConsSubs::get_date.
    and/or
2. Your package can define methods in the "cons" package so that
Conscripts can invoke them just like other cons methods.


        - Jeff.

-----Original Message-----
From: Gary Oberbrunner [mailto:address@hidden 
Sent: Tuesday, July 17, 2001 1:20 PM
To: Cons-Discuss
Subject: Packages and cons

I'm not a perl package expert.  I'm getting a bit confused about the
various
packages used by cons, and where I should put things.

Let's say I'd like to define a set of useful subroutines in
cons-subs.pl,
and 'require' them into my Construct so that all Conscripts can use them
without doing anything further.  Is that possible?  Here's what I've
tried:

Force every Conscript to do 'require Cons-subs.pl' at the top.  This
works
but requires modifying all the Conscripts.

In Cons-subs.pl, do 'package main' and then in the Conscripts call the
functions like ::get_date().  The extra colons seem superfluous, but I
don't
know how to get rid of them.

Make Cons-subs.pl into a Perl Module (ConsSubs.pm), export all the
desired
methods, then in Construct write 'use ConsSubs;'.  I thought this would
propagate to the Conscripts, but it doesn't, I guess because those
imports
get cleaned from the script package after reading Construct.  So I'm
back to
having to include a line in each Conscript.



So here's my question for you: Is there any way to define functions in
the
top-level Construct (or a file require'd by it) in such a way that they
can
be used in all Conscripts without package qualifiers?  Or would this
just be
a Bad Idea (tm)?

thanks all,

. . . . . . . . . . . . . . . . . . . . . . . . .
Gary Oberbrunner                address@hidden
GenArts, Inc.                   Tel: 617-492-2888
8 Clinton Street                Fax: 617-492-2852
Cambridge, MA 02139 USA         http://web.genarts.com


_______________________________________________
address@hidden
http://mail.gnu.org/mailman/listinfo/cons-discuss
Cons URL: http://www.dsmit.com/cons/



reply via email to

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