From: "David A. Black" Date: 2004-12-09T05:10:34+09:00 Subject: Re: Freezing Variable Assignment Hi -- On Thu, 9 Dec 2004, itsme213 wrote: > > "Florian Gross" wrote in message > news:31mf3tF3ebu1mU3@individual.net... >> itsme213 wrote: >> >>> I was talking about the pure object model part of Ruby. In such a pure >>> object model, a[1] and a[2] are instance variables (some Smalltalk >>> descriptions calls these 'indexed instance variables' as opposed to > 'named >>> instance variables'). How something is optimized in C is a different > matter. >> >> Please call this Object state ("as in a[1] and a[2] are part of Object >> state" / "@foo is part of Object state") instead. It's a more general >> term and seems to already be well-established. > > Perhaps. > > Though it's hard to say "object x has states a, b" when you mean "object x > has instance variables a, b". Or "object x has states 1, 2, 3" when you > mean "object x has indexed variables (indices?) 1, 2, 3". > > Object#each_instance_variable ? > Object#each_state ? > Object#each_slot ? > > It's not a big deal, but a common term would be nice. I don't think there is one that really covers it, though. I tend to agree with Austin that finding such a term is a solution in search of a problem (I've never found it unclear to refer to instance variables as instance variables, array elements as array elements, hash key/value pairs as hash key/value pairs, etc., rather than trying to tie it all together) -- but also, consider what Ruby objects can do, and the ways they are known: obj = Object.new def obj.[](x) rand(100) end What is obj's state, as reflected in its indices? Let's ask it: irb(main):006:0> obj[1] => 64 irb(main):007:0> obj[2] => 57 irb(main):008:0> obj["hi"] => 21 One might be tempted to say: well, those aren't "real" indices. But that's the thing. Ruby is *fundamentally* built on dynamism and elastic behaviors of this kind. "Real" indices in Ruby (such as array indices) are what the indices in my example are: calls to a method. My example is obviously designed as a kind of puzzle -- but real Ruby objects masquerade as things, assume various behaviors on the fly, delegate actions to each other, and so forth, all the time. This is not to say that my object, above, contains 57 no more or less than the array [57] contains 57. It contains it less -- but the point is that Ruby is full of ways to make things like that not matter and/or be very difficult to establish in the first place. (And does my object contain 57 less than (0..99).to_a does? :-) David -- David A. Black dblack@wobblini.net