Why Java Doesn't Need Operator Overloading (and Very Few Languages

Daniel Keep daniel.keep.lists at gmail.com
Thu Apr 16 05:47:27 PDT 2009



Yigal Chripun wrote:
> On 15/04/2009 18:50, BCS wrote:
>> Hello Yigal,
>>
>>
>>> sounds silly to me. Why not simply generalize and allow defining
>>> in-fix functions like in functional languages? that also includes
>>> allowing
>>> any unicode character[s].
>>
>> lexing and (more importantly) parsing become a major problem if you
>> allow that
>>
>>
> Since it is done in other languages (for example Scala), I'm sure it's
> not impossible to implement.
> I don't think Scala is that much more troublesome to lex/parse.

That's not a very good argument.  Lots of things are possible; doesn't
mean they're a good idea.

Operator precedence determines how expressions are parsed.  Having
user-defined operators would require the code to be parsed once to get
the operator definitions, then re-parsed with a different meaning.  Euch.

That said, I'm OK with adding operators with well-defined meanings to
the language on an as-needed basis.  opDot, opUnion, opCross, etc.

  -- Daniel



More information about the Digitalmars-d mailing list