From: dblack@... Date: 2007-03-03T13:20:20+09:00 Subject: Re: Duck Typing Hash-Like Objects Hi -- On Sat, 3 Mar 2007, Rick DeNatale wrote: > Now you are right that it's often hard to name a role, but never say > never. The name might stand for a complex type like Romeo, Othello, > or Tony Soprano, or it might be a noun phrase like "mass which can be > conveniently accelerated...". It's not that there aren't things-that-can-be-named, but that I don't use the word "type" to refer to any of those things in Ruby. You can say things like "This object is Enumerable", or "This object implements what lots of people think is a hash-like interface". But those aren't the object's type, though they may tell you part of the picture. In fact, I find the word "type" pretty useless in connection with Ruby. It's possible to come up with some salient characteristic of how Ruby objects are engineered, and call that "type", but I've never found the word really useful. My characterization of it as circular (an object is of type "the type of objects of this type") is really another way of saying that it's not a very useful term. It doesn't, to borrow from one of your analogies, hit any of the available nails on the head :-) So I think we should really talk about interesting ideas like roles and behaviors and encapsulation, and forget "type". > The point though is that naming it isn't enough. Again in an > analogy with writing a play, the playwright's conception of the role > doesn't usually spring full-blown when the character's name gets > written down, but evolves as the play is written and the character > interacts with other characters in the play, and then further > evolves as the director begins to interpret the play. > > Imagine Shakespeare writing Romeo and Juliet in C++, he'd have to > pre-declare all the players, and come up with strong types closely > bound to the implementation of the actors, before he wrote a line of > dialog. I don't think this is what's at stake in any of this discussion, though. We're all hip to the dynamicness of Ruby :-) No one's talking about static typing. But I'd be happy to experiment with a moritorium on the word "type". David -- Q. What is THE Ruby book for Rails developers? A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) (See what readers are saying! http://www.rubypal.com/r4rrevs.pdf) Q. Where can I get Ruby/Rails on-site training, consulting, coaching? A. Ruby Power and Light, LLC (http://www.rubypal.com)