comp.lang.ada
 help / color / mirror / Atom feed
From: mheaney@ni.net (Matthew Heaney)
Subject: Re: Question about base types
Date: 1997/02/09
Date: 1997-02-09T00:00:00+00:00	[thread overview]
Message-ID: <mheaney-ya023680000902970112050001@news.ni.net> (raw)
In-Reply-To: dewar.855461358@merv


In article <dewar.855461358@merv>, dewar@merv.cs.nyu.edu (Robert Dewar) wrote:

>Yes, it is true that Ada 83 was a little confused in this area, but the
>terminology chosen in Ada 95 is fundamentally confusing, and in fact I
>note a couple of error messages in GNAT that are absolutely correct
>but which always cause people trouble:
>
>   package x is .... -- oops forgot this hid "type" x 
>
>      q : x;
>          |
>     Error: subtype name expected
>
>Almost all programmers react to this message thinking, "why do I need a
>subtype here, a type should be good enough"

Then we have to teach them that "types" don't have a name, only subtypes do.

>
>The fact that
>
>  type x is ...
>
>introduces the subtype x is bound to be confusing.

But we had first named subtypes even in Ada 83.  This declaration is
(simply) explained as "This declares a type whose first named subtype is
x."

>
>Sometimes we just decide to use the obvious terminology in GNAT instead
>of the technically correct termiology, and we probably should do that
>here too -- the message "type name expected
>would be much clearer in this instance.

Agreed.

>
>For example
>
>    subtype x is integer range 1 .. 10;
>    for x'size use 5;
>
>GNAT says "rep clause cannot be given for subtype"
>
>
>which is I think clear to people (at least no one ever asked for an
>explanation of this message).

I think it's ambiguous.  Do you mean a first named subtype, or non-first
named subtype?

>
>More accurate would be to say
>
>  "rep clause may only be given for first named subtype"
>
>but this seems more confusing to us.

Disagree.  That is the message I would *expect* to see.


>
>As Bob said, a bit of a mess, and as I say, in my opinion, definitely NOT
>improved in Ada 95 -- I preferred the Ada 83 terminology here (actually
>there are a number of instances where Ada 95 has changed Ada 83
>terminology that I think are ill-advised and cause confusion, but this
>is the most noticable of them).


I'm not disagreeing that this issue can be confusing; after all, I was the
one who submitted the original post!  When I was learning Ada 83, I
accepted that "first named subtypes" needed some special syntax to call
that fact out.  I think Ada 95 does improve things by always using the term
"subtype" instead of Ada 83's "type or subtype."

After all, we can always refer to the name of the subtype that appears in a
declaration that introduces a type as the "first named subtype," and refer
to other subtypes in that family as "non-first subtype."

But I'll admit it was only after a few years of using Ada 83 that I started
to understand all this business.

It is explained in some books, though, such as Barnes' Programming In Ada
and Bryan & Mendel's excellent Exploring Ada.  (You are even quoted in
there, Robert, about the price of houses in Palo Alto.)  Sadly, the latter
books (2 vols) are out of print.

--------------------------------------------------------------------
Matthew Heaney
Software Development Consultant
<mailto:matthew_heaney@acm.org>
(818) 985-1271




  reply	other threads:[~1997-02-09  0:00 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-01-26  0:00 Question about base types Matthew Heaney
1997-01-27  0:00 ` Mats Weber
1997-01-28  0:00   ` Robert A Duff
1997-01-29  0:00   ` Robert Dewar
1997-01-27  0:00 ` Robert A Duff
1997-01-30  0:00   ` Matthew Heaney
1997-01-30  0:00     ` Robert Dewar
1997-01-30  0:00       ` Matthew Heaney
1997-01-30  0:00     ` Matthew Heaney
     [not found]     ` <EACHUS.97Feb3221558@spectre.mitre.org>
     [not found]       ` <dewar.855063927@merv>
     [not found]         ` <EACHUS.97Feb6145918@spectre.mitre.org>
     [not found]           ` <dewar.855276722@merv>
1997-02-07  0:00             ` Mats Weber
1997-02-08  0:00               ` Robert Dewar
1997-02-10  0:00                 ` Mats Weber
1997-02-11  0:00                   ` Robert Dewar
     [not found]         ` <32FB45D4.2160@watson.ibm.com>
1997-02-10  0:00           ` Robert Dewar
1997-02-08  0:00   ` Robert Dewar
1997-02-09  0:00     ` Matthew Heaney [this message]
1997-02-09  0:00       ` Robert Dewar
1997-02-09  0:00         ` Matthew Heaney
1997-02-10  0:00           ` Robert Dewar
1997-02-10  0:00       ` Larry Kilgallen
1997-02-11  0:00   ` Robert I. Eachus
1997-02-12  0:00     ` Robert Dewar
1997-01-28  0:00 ` Robert I. Eachus
1997-01-28  0:00   ` Mats Weber
1997-01-29  0:00 ` Robert I. Eachus
1997-01-30  0:00   ` Robert A Duff
replies disabled

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