TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

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

Print Reply
"Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
Matthew Heaney <[log in to unmask]>
Mon, 26 Apr 1999 14:14:04 -0400
"Robert I. Eachus" <[log in to unmask]>
"Robert I. Eachus" <[log in to unmask]>
text/plain; charset="us-ascii"
text/plain (45 lines)
At 02:16 AM 4/25/99 -0700, Matthew Heaney wrote:
>It may seem like heresy to say so, but I think it was a mistake for the
>language to allow a programmer to override predefined operators of a
>(scalar) type.  "+" should always mean "+", and "/" should always mean

   It is a matter of orthogonality.  One of the main goals of the language
was to allow meaningful declarations like:

   function "*" (L, R: Meters) return Square_Meters;

   It seems silly to have rules which allow this, but do not allow:

   function "+" (L, R: Meters) return Meters;

   At first it seems like you can create a simple rule, but lots of binary
operators have either a return result of another type or two different
argument types.  For example:

   function ">" (L, R: Integer) return Boolean;


   function "&" (L: Character; R: String) return String;

   to go through all five permutations (AAA, AAB, ABA, ABB, and ABC) for
each binary operation describing what overloadings are and are not allowed
would have been just too confusing.  As it happens, the only restrictions
to remain in Ada 83 were those in section 6.7, mostly on "=' and "/=", and
the fact that there is no syntax in Ada 83 for overloading/overriding
assignment or attributes.  Notice that in Ada 95, all of those restrictions
where trimmed back, and the only new (effective) restriction is on certain
multiplication operations for fixed point types.  (You can overload the
operations, but you can't override the predefined universal fixed
operations.  So some statements that were legal in Ada 83 are not legal in
Ada 95.  This only occurs in very unusual cases, but the irritating thing
is that there is no easy fix if you do run into it.)

                                        Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...