On Thu, Apr 23, 2009 at 3:54 AM, Robert Klemme
<shortcutter / googlemail.com> wrote:

> More precisely: they must have identical /signatures/. This is polymorphism.
>
> If only the name is identical, it is /overloading/. Overloading can
> occur in a single class or in a class hierarchy.
...

> Of course the story gets more complicated if you have different length
> argument lists etc.

I'm not disagreeing with you Robert, but I need to point out that the
concept or equivalent of the 'name' of a method varies with the
language,  to avoid confusion, let's call the token which identifies a
group of polymorphic methods the method token.

In Ruby, the method token is quite simple, it's a simple identifier.

def foo
end

the name of this method is foo.

In Smalltalk, or Objective-C, the token (called a method selector in
Smalltalk, or just a selector in Objective-C) is either as simple
identifier for a method with no parameters which Smalltalk calls unary
messages, or the concatenation  one or more simple identifiers each
followed by a colon one for each parameter called keyword messages in
Smalltalk.

Smalltalk also has binary messages/selectors for things like
arithmetic and comparison methods, these selectors are s string of
characters from a restricted set, e.g. + or <=

MacRuby uses a hybrid of the Ruby and Objective-C selector, in
MacRuby, a call of the form

x.foo(1, :bar => 2, :baz => 3)
or using the Ruby 1.9 syntax
x.foo(1, bar: 2, baz: 3)

uses a selector of foo:bar:baz mapping the Ruby practice of using a
final hash parameter to provide 'keyword arguments' to Objective-C
style selectors (actually directly to Objective-C selectors). I'm not
sure what tricks MacRuby has up its sleeve for dealing with the fact
that in normal Ruby

x.foo(1, :bar => 2, :baz => 3)
and
x.foo(1, :baz => 3, :bar => 2)

invoke the same method, and have the same effect.

In a statically typed OO language like C++ or Java, the method token
also tied to the highest class in the hierarchy of a type which
introduces a name.  If overloading/generics are supported by the
language then it may also be tied to the parameter types.

It's these kind of subtleties which confound multi-language discussions.

-- 
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale