Re: Defining polymorphism vs. overloading

px@fctunl.rccn.pt (Joaquim Baptista [pxQuim])
20 Sep 90 14:53:19

          From comp.compilers

Related articles
[14 earlier articles]
Re: Defining polymorphism vs. overloading pardo@cs.washington.edu (1990-09-07)
Re: Defining polymorphism vs. overloading mmengel@cuuxb.ATT.COM (1990-09-11)
Re: Defining polymorphism vs. overloading freek@fwi.uva.nl (1990-09-10)
Re: Defining polymorphism vs. overloading pcg@cs.aber.ac.uk (Piercarlo Grandi) (1990-09-13)
Re: Defining polymorphism vs. overloading voss@suna0.cs.uiuc.edu (1990-09-14)
Re: Defining polymorphism vs. overloading stt@inmet.inmet.com (1990-09-15)
Re: Defining polymorphism vs. overloading px@fctunl.rccn.pt (1990-09-20)
Re: Defining polymorphism vs. overloading pcg@compsci.aberystwyth.ac.uk (Piercarlo Grandi) (1990-09-20)
Re: Defining polymorphism vs. overloading chip@soi.com (Chip Morris) (1990-09-15)
| List of all articles for this month |

Newsgroups: comp.compilers
From: px@fctunl.rccn.pt (Joaquim Baptista [pxQuim])
In-Reply-To: stt@inmet.inmet.com's message of 15 Sep 90 14:32:00 GMT
Keywords: polymorphism
Organization: Universidade Nova de Lisboa -- Lisbon, Portugal
References: <19400003@inmet>
Date: 20 Sep 90 14:53:19

In article <19400003@inmet> stt@inmet.inmet.com writes:


      Here is my favorite so far:


      > - Overloading is the ability to have the same name (symbol) attached
      > to different entities (functions, procedures, variables or whatsoever).
      >
      > - Polymorphism is the ability to have the compiler decide *at runtime*
      > which entity to use depending on the runtime type (class or whatever)
      > of the contents of variables.
      >
      > - Generic code is a chunk of code that has the ability of performing
      > the same algorithm with more than one type. The actual types may be
      > known at runtime (as in Smalltalk) or at compile time (as in Ada).
      > . . .
      > Joaquim Manuel Soares Baptista, aka px@fctunl.rccn.pt, px@unl.uucp


      However, I would revise the definition of polymorphism as follows:


      - Polymorphism is the ability to have a single entity (usually a parameter or
      a pointer) refer to objects/values of more than one type. Run-time
      polymorphism (like C++) allows the dispatch to type-specific code to be made
      at run-time. Compile-time polymorphism (like Ada's generics) performs the
      "dispatch" to type-specific code at compile-time.


It's always nice to be appreciated, but still I must disagree with you.


I disagree with your difference of run-time vs. compile-time polymorphism. I
call the first polymorphism and the second one overloading.


Although they look similar, they have a different expressive power. Run-time
dispatching is more powerful than compile-time "dispatching", and I think
that they deserve different names, ie, polymorphism and overloading.


I can elaborate on this "expressive power" business if that proves to
be necessary.
--
Joaquim Manuel Soares Baptista, aka px@fctunl.rccn.pt, px@unl.uucp
Snail: CRIA, UNINOVA, FCT/UNL, 2825 Mt Caparica, Portugal
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.