dblack / superlink.net wrote: >I'm finding this thread interesting enough that I shall risk (a) >hair-splittage; and (b) revelation of ignorance, in order to take it >further. > >What I'm now getting curious about is the use, utility, and stability >of the whole notion of an 'attribute' in Ruby. It seems like there's >no such thing as saying, from the outside (i.e., from the perspective >of someone using the class), "This object has a 'blah' attribute" -- >which I think is essentially the Uniform Access Principle in action, >but it goes further because even when something is (as close as we get >to) an attribute, it's still just a method that happens to return an >instance variable. Even from the class writer's perspective, it's not >qualitatively different from writing any other method (the way, say, >using global variables feels qualitatively different from using local >variables). > >This is what I was groping at in saying earlier that there's no >separate category of 'attribute' at the language level; it's woven >from the same cloth, so to speak, as all the code around it, but >happens to fulfill a kind of attribute-like function. Or is that too >mushy a way of looking at it? > I don't think it's 'too mushy.' One could argue that Ruby's flexibility in moving between the method and attribute concept is a feature and only causes confusion when one is coming from a background where the distinction is forced. > >I find this all interesting in part because it's something I keep >seeing in Ruby: incredibly simple, consistent, homogenous language >design from which one *can* -- but does not have to -- build and name >constructs which resemble those in other OO languages (all those ones >I don't know :-) My favorite example is class methods, and the fact >that they are essentially singleton methods added to Class objects by >the same mechanism that singleton methods are added to any other >object -- and that what gives them special-citizen status is that the >concept of a class method exists already and has some proven utility. > >It seems to me that if some day everyone decides that 'attribute' is a >superfluous category, or that class methods shouldn't be looked at as >different from other singleton methods -- or if new concepts at that >level of abstraction come into being -- Ruby will be *incredibly* >ready, because these things can just sort of flow out of, and melt >back into, the language.... > > >David > > > Well said David. As an example I find that the Ruby syntax like this allows me to move from skeleton code to more richly featured code more easily: some_obj.connection.send( data ) When I first write the class of some_obj it might have one 'connection' and that is indeed the varible 'connection.' Later I come back and rewrite the class to contain multiple connections and then make 'connection' a method that picks the best connection (or whatever). This is a big time saver for me that works even if I didn't see it coming. Michael Garriss