Article View: comp.lang.objective-c
Article #220Re: Operator overloading
From: Ken Lerman
Date: Thu, 27 Dec 1990 19:10
Date: Thu, 27 Dec 1990 19:10
53 lines
2828 bytes
2828 bytes
In article <191@bosslog.UUCP> zack@bosslog.UUCP (Zacharias Beckman) writes: ->In article <1990Dec14.155211.6598@mprgate.mpr.ca> murphy@photon.mpr.ca writes: ->>Does Objective-C support operator overloading? ->> ->>Gail Murphy | Voice : (604) 293-5462 ->>MPR Teltech Ltd. | Fax : (604) 293-5787 ->>8999 Nelson Way, Burnaby, BC | E-Mail: murphy@mprgate.mpr.ca ->>Canada, V5A 4B5 | mprgate.mpr.ca!murphy@uunet.uu.net -> ->Nope; Objective-C is not capable of overloading per the definition of the word ->if you are coming from C++. I.e.: -> -> Overloading allows multiple functions with the same name to be defined -> provided their argument lists differ sufficiently for calls to be resolved. -> (ARM pp. 307). -> ->In other words, you can't overload a function, method or operator in ->Objective-C. It's unfortunate -- I really miss this capability, particularly ->in method overloading. -> ->-- ->Zacharias J. Beckman | God grant me Serenity to accept things I can't change, ->Lower Code Dweller | Courage to change those I can, ->Boss Logic Inc. | and Wisdom to know the difference. ->uunet!bosslog!zack | --- Sinead O'Conner. IMHO the polymorphism available through Objective-C qualifies as operator overloading. More specifically, two classes may have methods with the same name (actually, with the same selector). The user of the method may be oblivious to the fact that two such functions exist, and the proper function will be automatically called based on the receiver. In Objective-C, the proper method is executed based on the class of the receiver, rather than the type of the arguments, but from a functional point of view, the receiver is one of the arguments of the method. IMHO the quotation from the ARM is a description of what C++ provides rather than a definition of operator overloading. I'd be interested in hearing more details of what method overloading functionality is missing which lead Zacharias to write: "I really miss this capability, particularly in method overloading." As an old time Objective-C programmer, I might be able to offer some suggestions. As always, the preceding is my opinion, not necessarily that of Stepstone, and may the force be with you. Ken
Technical Details
Message-ID:
<5952@stpstn.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!rutgers!sun-barr!cs.utexas.edu!uunet!hsi!stpstn!lermanReferences:
<1990Dec14.155211.6598@mprgate.mpr.ca> <191@bosslog.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!rutgers!sun-barr!cs.utexas.edu!uunet!hsi!stpstn!lerman From: lerman@stpstn.UUCP (Ken Lerman) Newsgroups: comp.lang.objective-c Subject: Re: Operator overloading Message-ID: <5952@stpstn.UUCP> Date: 27 Dec 90 19:10:30 GMT References: <1990Dec14.155211.6598@mprgate.mpr.ca> <191@bosslog.UUCP> Reply-To: lerman@stpstn.UUCP (Ken Lerman) Distribution: na Organization: The Stepstone Corporation, Sandy Hook, CT 06482 Lines: 53