From: Wilbert Berendsen Date: 2003-01-27T02:34:31+09:00 Subject: Re: "exclude" (was: Re: cascading configuration variables) -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sunday 26 January 2003 17:56, ts wrote: > >>>>> "W" == Wilbert Berendsen writes: > > W> well, I would think B and all ancestors of B. But the stuff from A > W> would still be available, because it also got included in C. > > Unfortunately no : ruby never include twice the same module. If you > remove A and B, the stuff from A will not be available for the class D I understand. But if every module has a list of (pointers to) different ancestors, then this would be easily done. # e.g.: (assume A,B,C,D exist) module E include A, B, C, D end # now module E has A,B,C and D mixed in. module F include E end Now F has 1 ancestor. E has 4. When ruby starts to search for a constant (or method or whatever) it first looks in F itself. Then in the ancestor that first got added, etc. When I would do "exclude E" from within F, it would simply delete the internal pointer to the E module. Now E would not be accessible any more. But this is all imaginary. In reality, is a mixed-in module really like a superclass? because a module can mix-in (include) another module in at any time of its life, but classes cannot inherit a superclass later on. to illutrate all my musings: module A KDE=true end module B KDE=false include A end B.module_eval "KDE" >>> false so at the moment A gets included in B, Ruby finds that there is already a constant with the name "KDE" and does not update it. But is this constant KDE now in B or in A? Because: module A KDE=true end module B include A KDE=false end issues a warning. Apparently, the "include A" from within B really sets the constant in B. Let me make clear, I understand (I hope:) how Ruby does it, but I'm just curious. all the best, Wilbert - -- Wilbert Berendsen (http://www.xs4all.nl/~wbsoft/) To understand recursion, one must first understand recursion. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE+NBu0x+vk367Vl7wRAvyRAJ49KngetlWBsPa9BZNylpLtXYH+TQCeJ7nL jW+udWi5EiFmrR5sq+4bhDQ= =1Pk0 -----END PGP SIGNATURE-----