Bar Protos, allowing Bar to access Foo.²²Thus, we have the case that if Bar attempts to use Foo's interface, it must either explicitly require Foo or raise an error. This only leaves one hole, whereby modules can interact without explicit requirements between them. If Foo were changed to add foobar to the Lobby instead of its namespace (thisModule), then Bar could access foobar through the Lobby. I think this is unlikely to pose a problem and it may actually be a good thing to allow users to circumvent some of the module system's requirements when they really want to.²²Even though this is a significant change to how namespaces are handled in Io, it will only break programs that attempt to refer to the slots they're adding through the Lobby. Those programs would need to be changed to refer use thisModule, instead.²²As a last note, since this is already a very long addition to the page (sorry!), I've basically removed the notion of explicitly declaring that a file is a module, in favor of having Io automatically treat the first file it loads and every required file after that implicitly as a module. Having a file declare itself a module breaks doFile() and requires the interpreter to keep track of more information.²²I call the module loading facility require() instead of import() because import(), to me, implies that you're making the definitions of a module available inside the current one. I view import() as a separate mechanism:²² require("Foo") # Make the Foo module object available.² Foo import("foobar") # Bring in the foobar object.²²It may be worthwhile to provide another module loader, request(), which defines the module object as Nil if it fails, instead of throwing an exception (as I imagine require() doing). This might be useful in combination with module versioning:²² request("GTK", majorVersion == 2)² if(GTK == Nil) then(² request("GTK", majorVersion < 2)² # Build a compatability layer for older versions of GTK.² )² # code common to all versions of GTK we support.²²or in general:²² request("ReadLine")² require("File") import("standardInput")² ...² # Use full line-editing capabilities, if ReadLine package is available.² expr += if(ReadLine, ReadLine readLine, standardInput readLine)² ...²²-dak²²------------------------------------------------------------------------------------²²References²²* The Non-Pareil module system²* The Fink project²* Python Package Index, http://www.python.org/pypi²* Scheme FAQ, question about module system,²http://www.schemers.org/Documents/FAQ/#id2835125²* IoDocumentationSystem -- A specification for automatically generating documentation²that relies on modules behaving predictably.²²------------------------------------------------------------------------------------²²Comments© type-z.org and
its contributing authors, 2001-2004.
Content is licensed under a
Creative Commons License.