"Christoph Rippel" <crippel / primenet.com> writes:

> I think this is fine except that Matz seems to have implemented
> ``instance module variables'' versus 'Module variables' (see
> below). You did not fully describe these concepts in your book (as
> far as I know) so it's probably okay (and too late for now) - well
> maybe it should be ...

I don't believe that modules have instance variables. Instead,
instance variables spring in to existence in the context in which they 
are used. Thus if a module has a function that references an instance
variable, and that module is included in a class, objects of that
class will have the variable

  module A
     def setVar(n)
       @var = n
     end
  end

  class B
    include A
    attr :var
    def doIt
      setVar("it's B")
    end
  end
    
  class C
    include A
    attr :var
    def doIt
      setVar("it's C")
    end
  end

  b = B.new
  p b.instance_variables    #=> []
  b.doIt       
  p b.var                   #=> "it's B"
  p b.instance_variables    #=> ["@var"]

  c = C.new
  p c.var                   #=>-:31: warning: instance variable @var not initialized
  c.doIt
  p c.var                   #=> "it's C"


    
> module Mod
> @inst                  # we could use attr.
> @@mod = "m"
> def ins
>   @ins
> end
> def mod
>   @@mod
> end
> end

Try compiling this with '-w'


Regards


Dave