Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Re: exporting methods when than one package in a file?

Reply
Thread Tools

Re: exporting methods when than one package in a file?

 
 
Rainer Weikusat
Guest
Posts: n/a
 
      09-24-2012
bugbear <bugbear@trim_papermule.co.uk_trim> writes:
> I am building a small object oriented class set; most of the methods
> apply to an instance, and I can handle these OK.
>
> However, some of the classes supply class (or global) functions.
>
> Since none of the classes are large, I would like the whole
> class set to be in a single file.
>
> Question; what is the best way that I can:
>
> * make sure each global function is available throughout
> the source file?
>
> * export (EXPORT!) all the global functions
> when the class set is "used" ?


You could add them all to the @EXPORT array. But if they're really
'class methods' I think you should be calling them like class methods,
that is, by either using an object of the proper class or the name of
it on the left side of a ->. When a subroutine is exported, what
really happens is that the coderef currently assigned to the
subroutine slot of the glob in question is assigned to the subroutine
slot of another glob. But since Perl is a dynamic language the
association between the original glob and the original coderef isn't
necessarily permanent: Any method could redefine any other method by
assigning a different coderef to the corresponding glob and such
changes will become visible to users of the class when they use
proper method calls to invoke methods but not if they import methods
as subroutines instead.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can one declare more than one signal on one line? Merciadri Luca VHDL 4 11-01-2010 02:00 PM
Is there a way to find the class methods of a class, just like'methods' finds the instance methods? Kenneth McDonald Ruby 5 09-26-2008 03:09 PM
exporting multiple modules from one dll? Andras Balogh Python 2 01-26-2006 06:54 PM
Exporting Favorites from one PC to another - XP Pro to XP Pro Treb Computer Support 1 11-29-2003 07:13 AM
Aliased setter methods behave differently than other methods? Jim Cain Ruby 7 07-18-2003 04:34 PM



Advertisments