comp.lang.ada
 help / color / mirror / Atom feed
From: mfeldman@seas.gwu.edu (Michael Feldman)
Subject: Re: GNAT-Problem  Set_Line(), Set_Col()
Date: 15 Nov 1994 17:41:12 -0500
Date: 1994-11-15T17:41:12-05:00	[thread overview]
Message-ID: <3abde8$t6u@felix.seas.gwu.edu> (raw)
In-Reply-To: CzBp9A.CoC@inmet.camb.inmet.com

In article <CzBp9A.CoC@inmet.camb.inmet.com>,
Tucker Taft <stt@spock.camb.inmet.com> wrote:
>>I know the usual arguments about portability and predefined types, 
>>but of course Text_IO.Count is also a predefined type with implementation
>>defined range, so the advantage is not at all obvious.
>
>The justification, if any, for a separate type is not because
>of the implementation-dependence of the range, but rather because
>there is some value in having a strong type distiction here.

I don't really see it.

>I personally think this was (mild) overkill in the strong typing 
>department.  On the other hand, there are those who are still annoyed 
>that the predefined type String is indexed by Positive rather than its
>own unique type, so I doubt if you can please everyone in this
>area.  "Use type" makes it a little more palatable to have multiple
>integer types running about in Ada 9X.

Well, I think it would be more palatable to be consistent. The same
justification for indexing String by Positive would justify using
Positive as the file count, as you point out below.

>As usual, there is the tension between naive and simple use,
>and the advantages provided by strong type checking.

Of course, but that is not enough in itself to justify the type.

The month, day, and year types in Calendar are mere Integer subtypes;
the index type in String is a mere Integer subtype; yet the record
count, column count, and line count - three different ranges with
different uses - are all the same new type.

>Since Set_Col and Set_Line are a bit more sophisticated than
>other Text_IO features, beginning to use them is perhaps a 
>good indication that it is time to start learning about the 
>advantages (and occasional mild annoyances ;-) of strong type 
>distinctions between numeric types.  It is an important
>strength of Ada, IMHO, that integers used for indexing into
>arrays are distinguishable by type.  If one thinks of the
>characters on a page as being in an array, then it is appropriate
>that Set_Col and Set_Line have their own "index" type (of course, 
>this line of reasoning argues that Set_Col and Set_Line really ought 
>each to have its own separate "index" type).

Indeed, and the same goes for String. And, truth to tell, for
Calendar.Month_Number, Day_Number, Year_Number. This is a mild
inconsistency, not a source of major grief in the language, but it
is aggravating enough that I'd hoped for a better language-lawyerly
justification than you gave, Tuck... Generally the design of Ada is
very careful and I hesitate to come down too hard on what look like
inconsistencies, because they usually are well-thought-out. IMHO,
this one is not. Oh well.

Cheers -

Mike Feldman
------------------------------------------------------------------------
Michael B. Feldman -  chair, SIGAda Education Working Group
Professor, Dept. of Electrical Engineering and Computer Science
The George Washington University -  Washington, DC 20052 USA
202-994-5919 (voice) - 202-994-0227 (fax) - mfeldman@seas.gwu.edu (Internet)
------------------------------------------------------------------------
         Ada on the World-Wide Web: http://lglwww.epfl.ch/Ada/
------------------------------------------------------------------------
"Non illegitimi carborundum." (Don't let the bastards grind you down.)
------------------------------------------------------------------------



  reply	other threads:[~1994-11-15 22:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-11-01 14:28 GNAT-Problem Set_Line(), Set_Col() Andreas Krohn
1994-11-12 15:49 ` Robert Dewar
1994-11-15 13:30 ` Norman H. Cohen
1994-11-15 17:36   ` Michael Feldman
1994-11-15 19:10     ` Tucker Taft
1994-11-15 22:41       ` Michael Feldman [this message]
1994-11-16  0:04     ` Norman H. Cohen
1994-11-16 13:48       ` Robert Dewar
1994-11-16  0:56     ` Keith Thompson
1994-11-17  2:50       ` Michael Feldman
replies disabled

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