Hi --

On Thu, 25 Aug 2005, Mark Volkmann wrote:

> Ah ... thanks for the explanation!  Had I been paying attention, I
> would have understood the distinction between attributes and instance
> variables from reading pages 32-33 in Pickaxe 2.
>
> That still leaves the question of why Structs have "members" instead
> of "instance variables" and why OpenStructs have neither.

If anything, I would say members correspond to attributes, not to
instance variables.  But really neither.  A Struct is just a class
that chooses to describe some of its capabilities as members.  These
can coexist with attributes:

   irb(main):001:0> S = Struct.new("S",:a,:b)
   => Struct::S
   irb(main):002:0> class S; attr_accessor :x; end
   => nil
   irb(main):003:0> s = S.new
   => #<struct Struct::S a=nil, b=nil>
   irb(main):004:0> s.x = 1
   => 1
   irb(main):006:0> s.instance_variables
   => ["@x"]
   irb(main):007:0> s.members
   => ["a", "b"]


There's some overlap in functionality (just as their is between
'method' and 'attribute'), but I think it's probably good to have a
different name for the very specialized thing that Structs have, which
is created and implemented differently from attributes in the attr_*
sense.


David

-- 
David A. Black
dblack / wobblini.net