From: Austin Ziegler Date: 2002-11-09T03:52:43+09:00 Subject: Re: understanding modules/classes On Sat, 9 Nov 2002 03:33:40 +0900, Eric Schwartz wrote: > Austin Ziegler writes: >> It does matter where you put it, to a degree. "include" simply >> includes the methods and classes from a module into the current >> object scope. The "standard" object scope is (more or less) the >> Object object. >> >> Thus, when I do: >> >> include MIME::Types >> >> Then I have made it so that I can call the MIME::Types functions >> without any specifiers (although it may not be a good idea to do >> so). > Okay, I'm still confused. I get the feeling that I just walked > right past the point without even noticing it. You seem to be > talking about Modules as if they're just collections of functions. > I see them as a way of implementing namespaces for Ruby objects, > which I see as necessary. It's both. 'include' effectively removes the namespace. See my most recent response to you on this. It works with classes, other modules, and functions, too. > Otherwise, as I understand it, if I defined a TestTableModel > class, and you do too, you will silently extend mine, instead of > creating an entirely new class (or better yet, warning you of the > problem and falling over and dying). Whereas if I hide them inside > a TestHarness Module, you'd have to explicitly "include" it to get > that problem, and at least at that point you can be presumed to > know what you're doing. This is correct, and that's why you want to leave it up to the user to do the include where they want to do it. -austin -- Austin Ziegler, austin@halostatue.ca on 2002.11.08 at 13.50.53