comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: Equality operator overloading in ADA 83
Date: 1997/04/26
Date: 1997-04-26T00:00:00+00:00	[thread overview]
Message-ID: <dewar.862105379@merv> (raw)
In-Reply-To: mheaney-ya023680002504970023550001@news.ni.net


Matthew Heaney said

<<Programmers innocently tried to do this:

declare
    S : String := F (...);
begin

Incredibly, that's illegal in Ada 83.  All that was required, though, was a
simple repair:>>


As usual, if you think something is incredible, it is probably because you
did not carefully study the arguments on both sides.

The reason that the above construct is illegal in Ada 83 is that it is
potentially confusing, since once you are allowed to make such a declaration
to a *variable* as opposed to a *constant*, then it sure looks as though
you should be able to assign new string values to S, which is correct,
and, in a *very* small step, it sure looks to people like you should be able
to assign a different sized string.

I often find Ada 95 programmers confused over this, and in particular you
see something like:

   S : String := "";

with the intention of assigning variable length values later, and the
Constraint_Error comes as a surprise. Note that if you try

   S : String;

you get from GNAT:

s.adb:1:23: unconstrained subtype not allowed (need initialization)

which seems like a correct message, but does not solve this confusion.

Yes, after some discussion in Ada 95, we decided that the balance between
utility and confusion should be reevaluated, and put in this confusing
feature (which we know is confusing) because the utility is perceived in
retrospect as being worth it.

Was this a good idea?
I am not sure ... I certainly see it causing a lot of confusion.

As to your comments about Ada programmers not understanding runtime
computed constants, surely not? Well I guess people can have all kinds
of misinformation, but it is a critical feature of Ada that you can
declare such constants, and indeed a criticism of much Ada code that I
see is that it unnecessarily uses variables, where constants would be
preferable.





  parent reply	other threads:[~1997-04-26  0:00 UTC|newest]

Thread overview: 114+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-04-21  0:00 Equality operator overloading in ADA 83 Manuel Wenger
1997-04-22  0:00 ` Kevin Cline
1997-04-22  0:00   ` Mark A Biggar
1997-04-24  0:00   ` Keith Thompson
1997-04-22  0:00 ` Matthew Heaney
1997-04-22  0:00   ` Philip Brashear
1997-04-22  0:00   ` Mats Weber
1997-04-22  0:00     ` Matthew Heaney
1997-04-23  0:00       ` Mats Weber
1997-04-23  0:00         ` Robert A Duff
1997-04-25  0:00           ` Kevin Cline
1997-04-25  0:00             ` Robert A Duff
1997-04-25  0:00             ` Matthew Heaney
1997-04-25  0:00               ` Robert A Duff
1997-04-25  0:00                 ` Jon S Anthony
1997-04-27  0:00                   ` Robert Dewar
1997-04-28  0:00                   ` Robert I. Eachus
1997-04-29  0:00                     ` Jon S Anthony
1997-04-26  0:00               ` Robert Dewar [this message]
1997-04-27  0:00                 ` Matthew Heaney
1997-04-27  0:00                   ` Robert A Duff
1997-04-26  0:00             ` Robert Dewar
1997-04-26  0:00               ` Matthew Heaney
1997-04-22  0:00     ` Robert A Duff
1997-04-22  0:00       ` Matthew Heaney
1997-04-23  0:00         ` Mats Weber
1997-04-23  0:00           ` Robert A Duff
1997-04-24  0:00             ` Mats Weber
1997-04-24  0:00               ` Robert A Duff
1997-04-24  0:00                 ` Robert Dewar
1997-04-25  0:00                   ` Robert A Duff
1997-04-26  0:00                     ` Nick Roberts
1997-04-26  0:00                       ` Robert A Duff
1997-04-26  0:00                         ` Robert Dewar
1997-04-27  0:00                           ` Robert A Duff
1997-04-26  0:00                             ` Robert Dewar
1997-04-28  0:00                               ` Simon Wright
1997-04-29  0:00                                 ` Robert I. Eachus
1997-04-26  0:00                       ` Robert Dewar
1997-04-26  0:00                         ` Matthew Heaney
1997-05-02  0:00                           ` Nick Roberts
1997-05-04  0:00                             ` Robert Dewar
1997-05-05  0:00                               ` Robert A Duff
1997-05-05  0:00                               ` Mats Weber
1997-05-05  0:00                                 ` Robert Dewar
1997-05-06  0:00                                   ` Matthew Heaney
1997-05-06  0:00                                     ` Robert Dewar
1997-05-07  0:00                                     ` Tucker Taft
1997-04-29  0:00                       ` Mats Weber
1997-05-01  0:00                         ` Robert Dewar
     [not found]                           ` <01bc571c$01f3ffc0$5de2b8cd@p5120.bda>
1997-05-03  0:00                             ` Robert Dewar
1997-04-27  0:00                     ` Robert Dewar
1997-04-27  0:00                       ` Fergus Henderson
1997-04-27  0:00                         ` Robert Dewar
1997-04-28  0:00                           ` Fergus Henderson
1997-04-28  0:00                             ` Robert Dewar
1997-04-25  0:00                 ` Mats Weber
1997-04-25  0:00                 ` Kevin Cline
1997-04-25  0:00                   ` Mats Weber
1997-04-25  0:00                     ` Robert Dewar
1997-04-29  0:00                       ` Mats Weber
1997-05-01  0:00                         ` Robert Dewar
1997-04-25  0:00                   ` Mats Weber
1997-04-27  0:00                     ` Robert Dewar
1997-04-29  0:00                       ` Mats Weber
1997-04-25  0:00                   ` Robert A Duff
1997-04-27  0:00                 ` Geert Bosch
1997-04-24  0:00               ` Matthew Heaney
1997-04-25  0:00                 ` Robert Dewar
1997-04-25  0:00                   ` Matthew Heaney
1997-04-26  0:00                     ` Robert A Duff
1997-04-26  0:00                     ` Robert Dewar
1997-04-25  0:00                 ` Robert Dewar
1997-04-25  0:00                   ` Matthew Heaney
1997-04-26  0:00                     ` Robert Dewar
1997-04-26  0:00                   ` Fergus Henderson
1997-04-26  0:00                     ` Robert A Duff
1997-04-26  0:00                       ` Robert Dewar
1997-04-27  0:00                     ` Robert Dewar
1997-04-28  0:00               ` Robert Dewar
1997-04-28  0:00               ` Robert Dewar
1997-04-29  0:00                 ` Mats Weber
1997-04-29  0:00                   ` Robert A Duff
1997-04-29  0:00                     ` Matthew Heaney
1997-05-02  0:00                       ` Tucker Taft
1997-05-02  0:00                         ` Robert Dewar
1997-05-02  0:00                           ` Robert A Duff
1997-05-03  0:00                             ` Robert Dewar
1997-05-01  0:00                   ` Robert Dewar
1997-04-29  0:00                 ` Matthew Heaney
1997-05-01  0:00                   ` Robert Dewar
1997-04-23  0:00           ` Robert Dewar
1997-04-24  0:00             ` Robert A Duff
1997-04-29  0:00             ` Mats Weber
1997-05-01  0:00               ` Robert Dewar
1997-04-24  0:00         ` Robert Dewar
1997-04-22  0:00       ` Mats Weber
1997-04-24  0:00     ` Robert Dewar
1997-04-24  0:00       ` Robert A Duff
1997-04-25  0:00         ` Robert Dewar
1997-04-25  0:00           ` Matthew Heaney
1997-04-26  0:00             ` Robert Dewar
1997-04-26  0:00               ` Robert A Duff
1997-04-26  0:00                 ` Robert Dewar
1997-04-26  0:00                   ` Matthew Heaney
1997-04-27  0:00                     ` Robert Dewar
1997-04-27  0:00                   ` Robert A Duff
1997-04-26  0:00                     ` Robert Dewar
1997-05-02  0:00                       ` Nick Roberts
1997-05-04  0:00                         ` Robert Dewar
1997-04-26  0:00                 ` Robert Dewar
1997-04-26  0:00                   ` Matthew Heaney
1997-04-27  0:00                   ` Robert A Duff
1997-04-22  0:00 ` Mats Weber
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox