Path: utzoo!utgpu!watserv1!watmath!att!ima!esegue!compilers-sender From: hrubin@l.cc.purdue.edu (Herman Rubin) Newsgroups: comp.compilers Subject: Re: Defining polymorphism vs. overloading Keywords: polymorphism, design Message-ID: <2509@l.cc.purdue.edu> Date: 3 Sep 90 12:55:57 GMT References: <9008310419.AA06194@karakorum.berkeley.edu> Sender: compilers-sender@esegue.segue.boston.ma.us Reply-To: hrubin@l.cc.purdue.edu (Herman Rubin) Organization: Purdue University Statistics Department Lines: 36 Approved: compilers@esegue.segue.boston.ma.us In article , burley@world.std.com (James C Burley) writes: > In article <9008310419.AA06194@karakorum.berkeley.edu> oliver@karakorum.berkeley.edu (Oliver Sharp) writes: > > o Overloading means using the same name (or symbol) to invoke different > code depending on the types of the arguments (or operands).... > > o Polymorphism means using the same piece of code to operate on objects > of different types. .................. > Conceptually, what is the difference? Let's look at our favorite overloaded > operator, addition: > > y + z > > Now if y and z can be of several valid types, we say that + is overloaded > because we know it must perform different actions depending on the types. Thus if y and z are long integers, this becomes (different assembler languages have somewhat different notation, and this may not correspond to any) ADDL y,z and if they are floating ADDF y,z Now ADDL and ADDF will operate on either, so those are polymorphic and not overloaded. -- Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907 Phone: (317)494-6054 hrubin@l.cc.purdue.edu (Internet, bitnet) {purdue,pur-ee}!l.cc!cik(UUCP) -- Send compilers articles to compilers@esegue.segue.boston.ma.us {ima | spdcc | world}!esegue. Meta-mail to compilers-request@esegue.