Valhalla Legends Forums Archive | General Discussion | Function Overloads == Polymorphism?

AuthorMessageTime
Myndfyr
I say no.

TheMinistered and I were having a debate about whether overloaded functions are a feature of polymorphic languages. I say no -- you can have a language that supports function overloads but is not polymorphic. VB6 *in theory* could support function overloads, just by having different parameters. But it's not a polymorphic language because you can't have one type change the base type's behavior.

This is my best example of polymorphism:

In Beta 1, the ProfileEx class contains ALL of the information required for my bot. It implements about 6 interfaces: IDisplaySettings, IConnectionSettings, ICommandSettings, etc. I pass ProfileEx to functions that don't know of the existence of ProfileEx, but do know of the existence of their respective interfaces. So, I say, .SetDisplaySettings(myProfile) where the SetDisplaySettings method takes an IDisplaySettings parameter. In some instances, ProfileEx behaves solely as display settings. Others, solely as command settings, or connection settings. None of those are aware of the existence of a ProfileEx class. That's what it means, for something to have many forms.

I fail to see how that has anything to do with overloaded functions. :P

[edit] My bad Tuber, I got you and TheMinistered confused. [/edit]
July 25, 2004, 2:05 AM
Tuberload
When exactly did I debate this with you?

Addition: What are you talking about anyways? I do not program in VB whatsoever.

Final addition: Ok that makes much more sense. Everyone please ignore my comments.
July 25, 2004, 2:06 AM
StrifeOS
Function overloading allows you to use the same function interface (name) for different implementations (definition). Actually, I guess the parameter list is part of the interface too, but that's just a small example. I'd actually see it more fit as function overiding as function polymorphism, not function overloading. I'm not absolutely sure how it ever came to be known as function polymorphism though.
July 25, 2004, 3:49 AM
Maddox
Overloading functions does not allow objects to "morph" into other ones, so no, I don't see it as a feature of polymorphism. It is simply a feature of a language.
July 25, 2004, 5:23 AM
Arta
I don't think overloading is polymorphism either.
July 25, 2004, 1:26 PM
warz
I dont think polymorphism is overloading. No. I think morphing is cool though. I'd like to morph into a bird; a bird of prey.. and eat humans.
July 25, 2004, 3:41 PM
Adron
I think function overloads is an example of polymorphism.
July 25, 2004, 5:12 PM
Tuberload
[quote author=Adron link=board=2;threadid=7862;start=0#msg72441 date=1090775553]
I think function overloads is an example of polymorphism.
[/quote]

I agree because the definition of polymorphism is many forms, and function overloading allows there to be many forms of one function. I believe the exact term is Ad-hoc polymorphism but I could be wrong.
July 25, 2004, 7:35 PM
kamakazie
[quote author=Tuberload link=board=2;threadid=7862;start=0#msg72471 date=1090784146]
[quote author=Adron link=board=2;threadid=7862;start=0#msg72441 date=1090775553]
I think function overloads is an example of polymorphism.
[/quote]

I agree because the definition of polymorphism is many forms, and function overloading allows there to be many forms of one function. I believe the exact term is Ad-hoc polymorphism but I could be wrong.
[/quote]

I believe you're correct. And I do agree function overloading is a form of polymorphism.

http://en.wikipedia.org/wiki/Polymorphism_%28computer_science%29
July 25, 2004, 7:51 PM

Search