From: Richard Kilmer Date: 2004-06-08T23:43:31+09:00 Subject: Expressing intent in method calling... This is not a continuation of the type thread other than trying to continue to discuss the ideas of adding metadata that could be used to help the runtime environment of Ruby. Before anyone says anything, I have built lots of Ruby code without this, and the runtime is just fine...think of this as exploration. Disregard all the other syntax I wrote on earlier...and I do not care whether something is Hash-like, or is_a? Duck ;-) class Person attr_accessor :name end def greet(person) puts "Hello there #{person.name}" end So, greet was coded thinking its sending the 'name' message to a Person object...and that is expressed with the metadata . o = Object.new def o.name if called_as?(Person) "Rich" else to_s end end You build your object to accept being called as a Person, but it can be called as anything else too...it just responds to the name method differently if its being asked 'as a Person'. greet(o) => "Hello there Rich" What this adds is the ability to express the intent of the caller as to what they mean by sending the message 'name' (ie. name, as in a Person's name). The receiver can find out the caller's intent (called_as?(Person)). It also lets the receiver change into what the caller wants it to be (kinda like become...one method at a time). -rich