From: Austin Ziegler Date: 2005-07-28T21:09:49+09:00 Subject: Re: What's so special about operators, built-in classes and modules? On 7/28/05, Devin Mullins wrote: > >The problem I have with this sort of proposal is that since > >classes keep state, if we allow the inclusion of Class objects, then > >we have to start worrying about the inheritance of that state, just > >like we do with normal Class inheritance. > I don't understand that argument. In the context of being "include"d, > Modules keep state, and suffer from no less than would Classes, if > includable, as far as I can tell. What am I forgetting? FYI, your quoting mechanism is off. IIRC, I wrote that, not James. When a module is mixed into a class, its references to instance variables are bound to the instance of the class. module Foo def baz @baz ||= 0 @baz += 1 end end class Bar include Foo def blat @blat ||= 0 @blat += 1 end end moof = Bar.new moof.instance_variables # => [] moof.blat; moof.instance_variables # => ["@blat"] moof.baz; moof.instance_variables # => ["@blat", "@baz"] If we include classes, then we have to start caring about the origin of instance variables. -austin -- Austin Ziegler * halostatue@gmail.com * Alternate: austin@halostatue.ca