comp.lang.ada
 help / color / mirror / Atom feed
From: kst@alsys.com (Keith Thompson)
Subject: Re: GNAT-Problem Set_Line(), Set_Col()
Date: Wed, 16 Nov 1994 00:56:39 GMT
Date: 1994-11-16T00:56:39+00:00	[thread overview]
Message-ID: <CzC5AG.65A@alsys.com> (raw)
In-Reply-To: 3aari4$jlc@felix.seas.gwu.edu

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

Well, I'd like to think of myself as an "Ada Wise Person".  8-)}

Why should the maximum number of lines in a text file be the same as
the largest value of type Integer?  Text_IO.Count is a predefined type,
but it's predefined by the implementer of Text_IO, who can choose a
reasonable range for it.

On some targets, you might want type Integer to be only 16 bits (this
was probably more true in 1983 than it is now, but it's still allowable).
Having Text_IO blow up on text files longer than 32767 lines would have
been A Bad Thing (though I suppose that, with careful implementation,
it wouldn't necessarily blow up unless you try to set or query the
current line number).

Overuse of the predefined types is considered (by many) to be bad style
anyway, since it weakens Ada's strong type checking.  It's too bad when
that checking complains about something that's actually safe, but that's
the price we pay for having the compiler detect more of our mistakes.
This is exactly what user-defined integer types are for.

function "+"(Left: Apples; Right; Oranges) return Fruits;

-- 
Keith Thompson (The_Other_Keith)  kst@alsys.com
TeleSoft^H^H^H^H^H^H^H^H Alsys, Inc.
10251 Vista Sorrento Parkway, Suite 300, San Diego, CA, USA, 92121-2718
/user/kst/.signature: I/O error (core dumped)



  parent reply	other threads:[~1994-11-16  0:56 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
1994-11-16 13:48       ` Robert Dewar
1994-11-16  0:56     ` Keith Thompson [this message]
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