in reply to Re: The costs of packages
in thread The costs of packages
What I am trying to succeeding in doing, is encapsulate several hundred datatypes (think C-style structs and unions) in such a way that they can be imported into a program on demand without requiring mass pre-declaration as would be the case with
use My::Types qw[typeA typeB typeZZY];
or
use My::Type::typeA; use My::Type::typeB; use My::Type::typeC;
or
use My::Types::Factory; my $typeA = My::Type::Factory->new( 'TypeA' ); my $typeB = My::Type::Factory->new( 'TypeB' ); my $typeZZY = My::Type::Factory->new( 'TypeZZY' ); my $varTypeA = $typeA->new(); my $varTypeB = $typeB->new(); my $varTypeZZY = $type->new();
I also don't wish to have every program carry the weight of several hundred unused types because it uses 1 of them, hence the need to use the autoload. My inspiration comes from the POSIX package.
I need the types to each be in a seperate package space because each type will have the same set of methods.
So, whilst I am quite happy with the technique I outlined from the use and implementation point of view, I am a little concerned that the first variation my consume more "glob space" than is necessary, and if the second variation would save any substantial amount of memory and/ or prevent or reduce any performance hit that (may or may not) result from the first, then I would accept the slightly more verbose syntax of the second over the first.
However, if there is little or no difference in the overheads of the two variations, then I will go with the former's reduce syntax.
Now, if you can show me an efficient way of doing this with "a hash and a single package" I'm all ears?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: The costs of packages
by perrin (Chancellor) on Sep 16, 2003 at 06:16 UTC | |
by BrowserUk (Patriarch) on Sep 16, 2003 at 06:36 UTC | |
by PodMaster (Abbot) on Sep 16, 2003 at 07:59 UTC | |
by BrowserUk (Patriarch) on Sep 16, 2003 at 20:31 UTC | |
by dragonchild (Archbishop) on Sep 17, 2003 at 13:35 UTC | |
| |
|
Re: Re: Re: The costs of packages
by demerphq (Chancellor) on Sep 16, 2003 at 09:06 UTC | |
by BrowserUk (Patriarch) on Sep 16, 2003 at 20:06 UTC | |
by demerphq (Chancellor) on Sep 17, 2003 at 21:56 UTC |