home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dtix!mimsy!alex
- From: alex@cs.umd.edu (Alex Blakemore)
- Newsgroups: comp.sys.next.programmer
- Subject: Re: Multiple init: functions defined
- Message-ID: <60157@mimsy.umd.edu>
- Date: 8 Sep 92 17:14:30 GMT
- References: <3575@richsun.cpg.trs.reuter.com> <1992Sep6.155059.13349@afs.com>
- Sender: news@mimsy.umd.edu
- Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742
- Lines: 33
-
- In article <1992Sep6.155059.13349@afs.com> greg@afs.com writes:> In artic
- > A selector name, like a C function, should only have one set of
- > argument types. [Think about it: you wouldn't write two C functions with
- > the same name, but different arguments, even if they were static to the
- > module in which they appeared. Well, you might, but you couldn't get a job
- > with my firm. 8^)]
-
- actually having several functions share a single name can be very useful.
- Its called overloading of course and exists in languages like Ada and C++.
-
- As long as the compiler can resolve the reference to the correct call,
- and you only overload semantically similar operations, it can be a great convenience.
-
- There's no need to remember half a dozen names for the same conceptual operation.
- you could then use just setValue: instead of setStringValue:, setIntValue:,
- setFloatValue: etc - the compiler can figure out which one you meant from the
- argument type and you can worry about other things. Its convenient for some
- of the same reasons that polymorphism is.
-
- The AppKit would be a lot simpler to learn if Obj C allowed overloading IMHO.
-
- of course it can be abused and lead to confusion - like most powerful features.
-
- I once saw someone spend hours trying to figure out why he got a division by zero
- error on a line that did not contain any division operators. It turned out he
- had redefined the operators to get a particular form of unit conversion (fine)
- and had cut and pasted the division routine into the multiplication routine.
-
-
-
- --
- ---------------------------------------------------
- Alex Blakemore alex@cs.umd.edu NeXT mail accepted
-