TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Proportional Font
Show HTML Part by Default
Condense Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sender:
"Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
X-To:
Date:
Wed, 21 Apr 1999 16:09:56 -0400
Reply-To:
Michael Feldman <[log in to unmask]>
Subject:
From:
Michael Feldman <[log in to unmask]>
Content-Transfer-Encoding:
7bit
In-Reply-To:
<[log in to unmask]> from "Tucker Taft" at Apr 21, 1999 11:46:31 AM
Content-Type:
text/plain; charset=us-ascii
MIME-Version:
1.0
Parts/Attachments:
text/plain (40 lines)
[said Tucker to Rick]

> > 1. Is it possible to generate user defined binary operators?
>
> No.
>
> > 2. If not, then why not?
>
> Presumably if you overload "+" or "*" you would do so only when you
> are defining an operation that has a lot in common with "+" or "*"
> respectively, and you like the "precedence" implied.   However, someone
> reading code scattered with the use of a "#" operator would have
> no way of "intuiting" what it means, nor what is its precedence.

Readability is an important issue here, and implementation is another.
Allowing arbitrary operator symbols would require the writer to
specify, somehow, what the precedence of the new operator was. This
would, in turn, require some new syntax to specify it, and would
also require compilers to support arbitrarily large and complex
precedence tables.

The next question would be "well, then, why not ternary operators
like the ? : thing in C?", etc. etc. That would result in a very
different Ada! Think of the syntax rules if each of us could
specify our own operators of arbitrary rank and precedence.
Nice thought (and has made for interesting research), but Ada
compilers are quite complex enough already.:-)
>
> The number of keystrokes saved by writing "Value1 # Value2" versus writing
> "Max(Value1, Value2)" was not felt to pay off in the long run,
> given that code is read much more frequently than it is written.
>
> At least that's the official rationale...
>
To put it a bit differently, operator overloading lets you add
semantic content to the language without changing the syntax.
Ada is extensible, but not _that_ extensible.

Mike Feldman

ATOM RSS1 RSS2