[1041] in java-interest

home help back first fref pref prev next nref lref last post

Operator underloading (was: overloading of operators)

daemon@ATHENA.MIT.EDU (Philip Gladstone)
Thu Aug 17 13:10:57 1995

Date: Thu, 17 Aug 95 09:40:33 EDT
From: Philip Gladstone <Philip.Gladstone@onsett.com>
To: java-interest@java.sun.com

Walter Smith wrote:

>Another issue:  If it looks small, it looks cheap.  That + sign may be
>costing unbounded amounts of space and time, but most people are trained to
>think it's a one-cycle integer add.  Sure, if you ask them, they may know
>what it is, but when they're quickly scanning the code, they pass right
>over it.

I propose that we do some operator-underloading. The + sign is already used
for integers and floating point. This leads to endless confusion, so I
propose that + is reserved only for integers, and that a new operator
("floatAdd" - if you like smalltalk syntax) or a class member function be
defined to add floats. 

This approach has some useful advantages - the comparison operator <
would be replaced by "floatLessThan", and we could eliminate the 
floating point <= operator entirely (as floating point numbers are
very rarely equal to other floating point numbers).

The readability of the language would improve - you wouldn't have to
worry about whether   10/4 is actually 2 or 2.5

Any more votes for operator underloading? :-)

Philip    


---
Philip Gladstone
Onsett International Corporation, Cambridge, MA


-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post