comp.lang.ada
 help / color / mirror / Atom feed
From: stt@spock.camb.inmet.com (Tucker Taft)
Subject: Re: GNAT-Problem  Set_Line(), Set_Col()
Date: Tue, 15 Nov 1994 19:10:21 GMT
Date: 1994-11-15T19:10:21+00:00	[thread overview]
Message-ID: <CzBp9A.CoC@inmet.camb.inmet.com> (raw)
In-Reply-To: 3aari4$jlc@felix.seas.gwu.edu

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

>In article <3aad5q$qn9@watnews1.watson.ibm.com>,
>Norman H. Cohen <ncohen@watson.ibm.com> wrote:

>>In article <395jba$kbs@tucs6.rz.tu-cottbus.de>, 
>>  ak@informatik.tu-cottbus.de (Andreas Krohn) writes: 
>>
>>|> When I use these functions with a variable then the compiler says
>>|> "Invalid parameter list in call".
>>|> If it is a number then it works. Where is the problem ?
>>
>>My guess is that you've declared the variables to be of type Integer.
>>Set_Line and Set_Col take parameters of the integer type Text_IO.Count.
>>(An integer literal is acceptable where a value of any integer type is
>>expected.)
>
>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.

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.

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

As usual, there is the tension between naive and simple use,
and the advantages provided by strong type checking.
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).

>Mike Feldman

-Tucker Taft   stt@inmet.com



  reply	other threads:[~1994-11-15 19:10 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 [this message]
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
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