On Thu, Aug 10, 2000 at 05:46:14PM -0400, Bennett Todd wrote:
> Today there's no difference. If the proposal under discussion were
> to pass, and packages' namespaces were to become local to the
> namespace where the "use" occurred, then perhaps main::whatever
> could be a common, stable, global that they could use for these rare
> variables that really need to be common from multiple invokers.
There's a strong implication here that we've just made package namespaces
heirarchical. I don't disagree (how's that for a wimpy statement?), but
think we need to go further. ....hmmmm....brain racing....mmmaybe this is
a good idea....
How does this sound --
Modules (packages) should have the option of declaring themselves to be
either rooted or relative in the name space. Thus a module which wanted
to guarantee it would have one and only one copy in residence could
declare itself
<<module foo.pm>>
package foo; # preserves current usage
my $var; # only one copy ever exists no matter how many
# modules load foo
while a relative would do
<<alternative version of foo.pm>>
package &foo;
my $var; # one copy per instance of loading of foo
In either case, main would load it with a simple
use foo;
and the package has control over what is shared and what is not. One
could even have mixes of shared and unshared with
package &foo;
use foo_shared;
my $var = "x"; # per-instance copy set
$::foo_shared::var = $var; # cross-instance copy set
local $::foo_shared::var as $var; # wow!
Yes, I like this.....