comp.lang.ada
 help / color / mirror / Atom feed
* Why one TYPE instead of the other?
@ 1987-09-25 13:16 Freeman Moore - 575-3507
  0 siblings, 0 replies; 2+ messages in thread
From: Freeman Moore - 575-3507 @ 1987-09-25 13:16 UTC (permalink / raw)



Okay, I seem to be overlooking something:

   type ONE is range 1 .. 10;                 -- type

           or

   type ONE is new INTEGER range 1 .. 10;     -- derived type

Why/When should I use one definition form instead of the other?

Thanks for any input,
Freeman Moore
FMOORE%eg.ti.com@relay.cs.net

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Why one TYPE instead of the other?
       [not found] <23613@ucbvax.Berkeley.EDU>
@ 1987-10-02 20:33 ` stt
  0 siblings, 0 replies; 2+ messages in thread
From: stt @ 1987-10-02 20:33 UTC (permalink / raw)



The first form selects an underlying implementation
based on the range, which must be specified via *static*
expressions.   This form may fail at compile-time if
the requested range cannot be supported by any predefined
type.

The second form specifies that predefined INTEGER
be used as the underlying implementation type,
and the range may be specified by arbitrary, potentially
run-time, INTEGER expressions.
This form will never fail at compile-time, but
may raise Constraint_Error at run-time if the range you
specify is outside of Integer'FIRST .. Integer'LAST.

Based on the above characteristics, the first form
is preferable when legal, since it is not dependent
on the relative sizes of the various predefined integer types,
and detects out-of-range problems at compile-time.

But as noted, it cannot be used if the desired bounds
are not static (which implies compile-time-known) expressions.

S. Tucker Taft
Intermetrics, Inc.
Cambridge, MASS

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1987-10-02 20:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <23613@ucbvax.Berkeley.EDU>
1987-10-02 20:33 ` Why one TYPE instead of the other? stt
1987-09-25 13:16 Freeman Moore - 575-3507

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