• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Polymorphism at compile time?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In a graduate-level software engineering course, a basic definition of polymorphism was given as the, "Ability of an entity to refer to objects of more than one type at runtime." Now I'm wondering whether those last two words are wrong. It seems that parametric polymorphism, at least in Java, happens at compile time since Java's generics are erased at runtime. Also, my understanding is that ad-hoc polymorphism happens at compile time as well, so the only run-time polymorphism in Java is the usual subtype polymorphism; but contrary to my earlier definition, the compiler is as capable of polymorphism as the VM. Am I understanding these things correctly?
 
author
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The polymorphism can be either compile or runtime. So saying "at runtime" makes its definition incomplete.
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It all depends how you define polymorphism. You have been given two different and conflicting definitions, one here, the other at your course. I would restrict the word polymorphism to what happens at runtime, myself, but as you see, some people use a different meaning.
 
Poornachandra Sarang
author
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is a quote from my book (pp 81):

"... This feature is called compile time polymorphism. The compiler resolves which implementation to call at the compile time, thus the name. We also have a feature known as runtime polymorphism whereby the Java runtime decides during the program execution which implementation to call."

As I have been claiming in the book and the posts in this forum, that the main focus was to bring in absolute (if not at least near absolute) technical accuracy in the book. So I have put in my best efforts in selecting the most accurate nomenclature throughout, coupled with rigorous technical reviews. I have seen the use of both terms "compile" and "runtime" in several literatures including Sun's official curriculum. I would like to add that in my earlier comment, I used the word "incomplete" which is more appropriate than calling it "conflicting".

I do not wish to start a debate on this and do respect the different opinions in the academics and the industry.
 
A Jaco
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Poornachandra Sarang wrote:I have seen the use of both terms "compile" and "runtime" in several literatures including Sun's official curriculum.


If it's not too much trouble, would you mind providing a link or two? I would like to check out the sources. I've been searching for an IEEE definition of polymorphism; but SE vocab doesn't have one.
 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I said earlier, people seem to use the word to mean several different things. Agree, a lengthy discussion would be unfruitful.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic