a name in two ways. Module Collisions: Modules can be modified, globally, from anywhere. Version Collisions: Two different versions of a module can’t be loaded.
ways. • A structured namespace: • Foo::Bar::Baz • Major scenario: • Top-level “Configuration” in gems • Typical RoR classes vs Ruby, Gems, etc (like “Guild”) • Two apps in a process (in the context of “Modular monolith”)
• Local names + Local Aliases • Java (classes w/ FQDN) • Global NameSpace + Library name • Class loaders (oops….) • Kotlin • Global NameSpace + Local Alias • Python (pip) • Global NameSpace (+ Local Alias) • Go • Local names + Local Aliases
of two versions at a time • Same name, Di ff erent (native) code, Di ff erent access path (local name) • Isolate libraries in speci fi ed namespaces at the required time (“on read”) Ruby Process LibraryX version: a.b.c “x.so” LibraryX version: x.y.z “x.so” ns1::X ns2::X
of two versions at a time • Same name, Di ff erent (native) code, Di ff erent access path (local name) • Isolate libraries in speci fi ed namespaces at the required time (“on read”) Ruby Process LibraryX version: a.b.c “x.so” LibraryX version: x.y.z “x.so” ns1::X X
wrap) • The wrap of load(filename, wrap): • works as a simple namespace • Introduce a sub-class of Module: NameSpace • works like the wrap of load • has instance methods #require, #load • Dependencies will be required/loaded in the namespace recursively
• Hard Things: Native extension MAY need to be updated, in case • Native extensions using others’ C-functions https://github.com/tagomoris/sequel_pg/pull/1 • TODOs: Upgrade path SHOULD be de fi ned • How can we mark a gem is namespace-ready? • How can we determine the namespace of a library? (RubyGems/Bundler) • Designs • What’s the namespace in Ruby? • Problems around the top-level names in namespaces
• “ns1::X” - A top-level name “X” de fi ned in a namespace “ns1” • It MUST be so, to isolate “ns1::X” from the “X” • “X” in the code isolated in “ns1” • It should be “ns1::X”, of course • But many gems add methods on “String” by “class String”… • “::X” in the code isolated in “ns1” • Should it be “ns1::X”? or the “X”? • “class ::String” should be possible