comp.lang.ada
 help / color / mirror / Atom feed
From: ncohen@watson.ibm.com (Norman H. Cohen)
Subject: Re: GNAT-Problem  Set_Line(), Set_Col()
Date: 16 Nov 1994 00:04:41 GMT
Date: 1994-11-16T00:04:41+00:00	[thread overview]
Message-ID: <3abiaq$qn9@watnews1.watson.ibm.com> (raw)
In-Reply-To: 3aari4$jlc@felix.seas.gwu.edu

In article <3aari4$jlc@felix.seas.gwu.edu>, mfeldman@seas.gwu.edu
(Michael Feldman) writes: 

|> I'd like to hear from Norm or another Ada Wise Person why it was thought
|> necessary to declare a new type for Text_IO.Count, instead of simply using
|> Positive.

In fact, in the Ada 80 RM, it was Positive.  By the July 1982 draft of
the revised RM, it had been changed to a new integer type.  I would guess
from the timing that the change was in response to a comment received
during the ANSI canvass.

It is easy to envision (and it was even easier to envision in 1980) a
16-bit machine for which the natural range for type Integer is
-32_768 .. 32_768, but for which files can easily exceed 32,768 lines (or
the single line of a file with only one line terminator can exceed 32,768
columns).  Then type Integer is not wide enough to serve in the role
played by Text_IO.Count.

|>           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.

It allows the implementation to define an efficient size for type
Integer, based on the width of a machine register, even if that type is
too small for numbering columns, lines, and pages in the target file
system.  Had a single type been used in the RM, the implementation would
have been forced to make type Integer wide enough to number columns,
lines, and pages, possibly imposing a substantial performance penalty
(doing all Integer arithmetic in terms of separate low-order and
high-order halves of a word) for a marginal purpose.  (How often do you
use Set_Line and its cousins?)

|> In my opinion, the use of a new type here causes exactly the kind of
|> confusion Andreas encountered; are the benefits of a distinct type in
|> this case worth it when balanced against the confusion?

I agree that a separate type here is a pain, but it appears to be a
decision made for pragmatic rather than aesthetic reasons.  (After all,
column numbers, line numbers, and page numbers are distinct abstractions,
so if the motivation were methodological, we would expect to see three
different types.  Note also that Text_IO.Field and Text_IO.Number_Base
ARE subtypes of Integer, because any realistic definition of type Integer
would be sufficient to accommodate the uses of those subtypes.)  I don't
think there was any other reasonable choice.

--
Norman H. Cohen    ncohen@watson.ibm.com



  parent reply	other threads:[~1994-11-16  0:04 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
1994-11-16  0:04     ` Norman H. Cohen [this message]
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