Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!mintaka!spdcc!esegue!compilers-sender From: dmw9q@uvacs.cs.Virginia.EDU (David M. Warme) Newsgroups: comp.compilers Subject: Re: Defining polymorphism vs. overloading Keywords: design, polymorphism Message-ID: <9009051416.AA29612@uvacs.cs.Virginia.EDU> Date: 5 Sep 90 14:16:53 GMT References: <9008310419.AA06194@karakorum.berkeley.edu> <4c98dcd0b.001a92c@caen.engin.umich.edu> Sender: compilers-sender@esegue.segue.boston.ma.us Reply-To: dmw9q@uvacs.cs.Virginia.EDU (David M. Warme) Organization: University of Virginia Computer Science Department Lines: 24 Approved: compilers@esegue.segue.boston.ma.us In article <4c98dcd0b.001a92c@caen.engin.umich.edu> Mark Montague writes: >So I imagine that every expression of the form > myarray[index] >is silently transformed into > *(myarray+index) >before the compiler even sees it. Even though it probably doesn't happen >this way for most compilers, this fictional device lets me ignore questions >of polymorphism and operator overloading in a non-object-oriented language >such as C. This does not remove polymorphism and/or overloading, it merely transfers the burden onto + and *. The expansion you state is THE DEFINITION of the operator. A C compiler I wrote does this during parsing by building two parse-tree nodes (* and +) rather than a single node for []. The only detail to consider is that the node used for * in this case is a specially-flavored * that differs in only one respect from the "normal" * node: error messages say "invalid subscript", rather than "illegal indirection". - Dave Warme -- Send compilers articles to compilers@esegue.segue.boston.ma.us {ima | spdcc | world}!esegue. Meta-mail to compilers-request@esegue.