From: Jean-Hugues ROBERT Date: 2004-06-09T05:45:14+09:00 Subject: Re: Expressing intent in method calling... At 03:32 09/06/2004 +0900, you wrote: >> On Jun 8, 2004, at 9:43, Richard Kilmer wrote: >> >>> 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 >> >> Isn't this effectively "to_name" or "as_name"? >> > >I am not trying to coerce the object into another representation in general >(although in the specific example its like that). Generally, I am trying to >add to the message something more than the message symbol and parameters...I >am trying to add the 'meaning' of the message as scoped in the namespace of >the provided class/module. I am trying to add to the method additional >semantics of what I am asking from the target object. I am sending the >message 'name' with the meaning that 'name' has on a Person object. That >receiver may or may not care...answering the way it wants, but right now I >cannot express that semantics at all. > >I guess I am not expressing myself with sufficient semantics ;-) > >-rich I think that you are clear enough. x..some_method() means that you want x to do what some_class does when some_method() is called. I don't like so much the called_as() thing because it looks inefficient to me. I would rather consider it as a something like method_missing. A more efficient solution would be to try to call a fully named method some_class.some_method() and default to some_method(): Some alternative syntax proposal: class Y def do_it(); end end class X implement Z # declarative def do_it(); if implement? Z then xxx else end end def Y.do_it(); end end y = Y.new; y.do_it() # Y's version of do_it() x = X.new; x.do_it() # X's version of do_it() x.Y.do_it() # X's version of Y's do_it() x.Z.do_it() # X's version of do_it() This may prove useful to resolve name clashes when implementing multiple Interfaces in a class. As a result an Interface would simply be an abstract class (or a Module maybe). Yours, Jean-Hugues ------------------------------------------------------------------------- Web: http://hdl.handle.net/1030.37/1.1 Phone: +33 (0) 4 92 27 74 17