🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.objective-c
Article #221

Re: Operator overloading

#221
From: Ken Lerman
Date: Thu, 27 Dec 1990 19:39
69 lines
3118 bytes
In article <192@bosslog.UUCP> zack@bosslog.UUCP (Zacharias Beckman) writes:
->In article <5928@stpstn.UUCP> lerman@stpstn.UUCP (Ken Lerman) writes:
->>In article <1990Dec14.155211.6598@mprgate.mpr.ca> murphy@photon.mpr.ca writes:
->>->Does Objective-C support operator overloading?
->>
->>Objective-C supports method overloading, but not operator (+, -,...)
->>overloading.
->
->Eh?  Not unless your using a better Objective-C compiler than I am!  I hope
->you are -- then I can upgrade!  Overloading is not the same as overriding;
->which is to say, the same method name in the same object with a different
->parameter list is overloading.  Objective-C doesn't support that for methods,
->functions or operators.  If I'm wrong, please let me know!
->
->-- 
->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.

If I had read this response prior to the previous one I just responded
too, my response would have been different.

It appears that we differ in our definitions of what method
overloading is.  At this point, I hope we understand the differing
definitions and will drop discussion of which is "right".

Objective-C permits:

Class A:
- foo:aFoo

Class B:
- foo:aFoo or
- foo:aBar

In this case, the implementation is chosen dynamically by whether the
receiver is an A or a B.  I would call this method overloading; I
believe Zacharias would not.

Objective-C also permits:

Class A:
- foo:(int)a

Class B:
- foo:(double)b

In this case, the implementation is chosen by whether the receiver is
an A or a B.  I would call this method overloading.  I don't know
whether Zack (pardon the familiarity) would.  If the wrong argument
type were supplied, Objective-C would generate an error.

To do this, though, the Objective-C compiler would have to know
whether the receiver is an A or a B.  You can do this in your code by
writing your declaration as: "A anObject;" or "B anObject;" as
appropriate.

As far as having a better Objective-C compiler than Zack has, I should
hope so.  The one I'm using hasn't been released yet.  :-) (This
functionality is in the language specification beginning with 4.0)

If Zack will send me email, or phone me at (203)426-1875, I can find
out about getting him an upgrade if necessary.

I write this as an exercise in freedom of speech without permission
from Stepstone.  May the force be with me.

Ken
Technical Details
Message-ID: <5953@stpstn.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!rutgers!usc!wuarchive!uunet!hsi!stpstn!lerman
References: <1990Dec14.155211.6598@mprgate.mpr.ca> <5928@stpstn.UUCP> <192@bosslog.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!rutgers!usc!wuarchive!uunet!hsi!stpstn!lerman
From: lerman@stpstn.UUCP (Ken Lerman)
Newsgroups: comp.lang.objective-c
Subject: Re: Operator overloading
Message-ID: <5953@stpstn.UUCP>
Date: 27 Dec 90 19:39:34 GMT
References: <1990Dec14.155211.6598@mprgate.mpr.ca> <5928@stpstn.UUCP> <192@bosslog.UUCP>
Reply-To: lerman@stpstn.UUCP (Ken Lerman)
Distribution: na
Organization: The Stepstone Corporation, Sandy Hook, CT 06482
Lines: 69