develooper Front page | perl.perl6.stdlib | Postings from June 2002

Re: More 6PAN musings: local namespaces

Thread Previous | Thread Next
Uri Guttman
June 17, 2002 03:28
Re: More 6PAN musings: local namespaces
Message ID:
>>>>> "DS" == Dan Sugalski <> writes:

  DS> At 6:10 PM -0700 6/16/02, Peter Scott wrote:
  >> It would be nice if one could say
  >> use Foo::Bar as Local::Foo::Bar
  >> as a way of expressing your proposal.

  DS> The one problem with that is modules that have multiple namespaces
  DS> in them. It's not too unusual for to have the packages Foo,
  DS> Foo::Bar, Foo::Bar::Baz, and Foo::Xyzzy in them. Which can
  DS> potentially lead to some interesting namespacing issues.

and peter mentioned a possible solution, a remap namespace inside each
module or namespace. when you are inside a given namespace (run or
compile time), all sub-namespaces mentioned are remapped through the
attached map. the use command could provide extra mapping info to handle
complex modules like dan mentions. in normal cases there is no remap
(only colliding spaces need this) so there is no speed or space penalty.

and that seems to be a simple and reasonable solution. it could handle
versioning too as you can remap a versioned module to its normal

	use Foo::Bar as Foo::Bar Version => 1.2.3 ;

or something like that. maybe the version could be part of the module
namespace itself:

	use Foo::Bar::1::2::3 as Foo::Bar ;

meaning, any trailing namespaces that are all digits can be interpreted
as a version. this also could work for 6pan and installiing a specific
version. and it offers a possible name collision solution. install the
colliding modules under different version numbers (but make them very
far apart!).

	use Foo::Bar::1::2::3 as Foo::Bar ;	# public module
	use Foo::Bar::1000 as Local::Foo::Bar ; # company module


Uri Guttman  ------  --------
- Damian Conway Perl Classes -- July 1-3 -- ---
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About