[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Java operator overloading
Etienne,
I think it would be interesting to implement, but terribly confusing
for the reader of the code. Both in the notation of algebra as well as
programming languages, associativity and precedence conventions for "+"
and "*" are ingrained into us. It would be hard to read the code if you
have to look at class implementations to determine precedence within an
expression.
What we want is fairly mundane - user-defined fixed and floating point
number formats without having to have one notation for arithmetic
using "int" and another one for "int20."
Maya
On Thu, 4 Mar 2004, Etienne Gagnon wrote:
> Hi Maya,
>
> Maya Gokhale wrote:
> > It is somewhat related, but not completely. We want to do operator
> > overloading as in C++, so that, for example, an infix "a + b" will invoke
> > a particular method in "a"'s class that understands "+" given an argument
> > of "b"'s class.
>
> So, how will you deal with "precedence & associativity overloading" which
> should go along with operator overloading? I know C++ simply does not
> redefine precedence and associativity of overloaded operators, but this
> seems wrong to me, as associativity and precedence are a part of the
> definition of an operator. In other words, if you are ready to add
> operator overloading, why not go all the way and fully implement it?
>
> Etienne
>
>
--
------------------------------
Maya B. Gokhale, maya@lanl.gov
nis-www.lanl.gov/~maya
505-665-9095
------------------------------