From: john maclean Date: 2009-04-23T08:15:59+09:00 Subject: Re: Back to Fundamentals 2009/4/22 Mike Stephens : > Phlip wrote: > >> >> That's "overloading", not "polymorphism". >> > > Before this thread I thought I understood polymorphism. Suddenly > confused, I went off to Wikipedia and there are all sorts of arcane > stuff there. I'm impressed how many technical terms people can use. > > Here's what I think it means: You can declare procedures (and, by > extension, operators) that have identical names (eg 'hire', 'sort', '+') > but behave differently depending on the nature of the object concerned. > This saves you generating unique names for each type of data. So > polymorphic means 'behaving differently in different situations'. > > If this is the case (forget all the different ways you might achieve > that), then Ruby must deliver mainstream polymorphism because it uses > classes. A class encapsulates procedures and therefore allows names to > be re-used. The appropriate behaviour is selected by the type of the > object concerned. > > Again if this simplistic view is correct, your examples are not to do > with Ruby and polymorphism, they are to do with making classes contain > more than one type of object (and why would you feel entitled to do > that?) > -- > Posted via http://www.ruby-forum.com/. > > May be a time to look at the So-called GOf "Gang of Fours"'s Design Templates. -- John Maclean 07739 171 531 MSc (DIC) Timezone: GMT