David A. Black wrote:
> Hi --
> 
> On Thu, 25 Aug 2005, Hal Fulton wrote:
> 
>>
>> Well, Structs are not implemented by using instance variables (well,
>> they are, but not the way you'd expect).
>>
>> If I were doing it, I would implement Structs so that there was a
>> one-to-one correspondence between members and instance variables.
>> Then this wouldn't be an issue.
> 
> 
> What if you wanted to add methods to the class, or one or more
> instances, that used instance variables in a non-member/attr-like way?
> It seems arbitrary to decide that Structs can't or shouldn't do that.
> 

Granted, but that's the opposite problem from the one I
have fought. If I understand you.

I didn't really mean one-to-one necessarily.

But what I have wished for is the ability to add methods that
referenced the members as normal instance vars (or attributes).

For example, if you have a member named "alpha" you access it
from the outside just like any accessor. That leads you (me)
to believe that it corresponds to an instance var @alpha (as if
we had said attr_accessor :alpha). But it doesn't.

Some people (read: me) have incorrectly assumed that Struct is
"shorthand squared" for defining a class, an initialize, and
a bunch of accessors. But the behavior is different.

Clear? Yeah, I know, there is still some point on which you
disagree. ;)


Hal