From: "Robert I. Eachus" <eachus@mitre.org>
Subject: Re: null range from 1 element discrete type
Date: 1999/11/19
Date: 1999-11-19T22:50:25+00:00 [thread overview]
Message-ID: <3835D5A0.F906D31D@mitre.org> (raw)
In-Reply-To: v03020900b45ad0cb9379F@[192.54.146.15]
Duncan Sands wrote:
>
> Suppose I have a discrete type (eg an enumeration type) T
> containing just one element. I would like to define a subtype
> with a null range. If T had more than one element, I could use
> T'Last .. T'First, but this won't work here. How to get a null
> range in this case?
>
> As you may guess, I have a generic package that takes a discrete
> type parameter T, and I want it to work correctly in this degenerate
> case. At some point the package declares an array type, eg
> type A is array (T range <>) of Float;
> and I want to declare a null slice of type A. At this point
> I run into the above problem...
Technically there is no "perfect" solution, as the compiler is
allowed to choose a size of zero bits for such a type. But if the
(sub)type is a generic formal type, you shouldn't have to worry about
this possibility.
Since you always want a null range try: T'Val(1) .. T'Val(0) Since
'Val returns the base type of T, as long as the base type of T contains
at least one bit you are safe.
--
Robert I. Eachus
with Standard_Disclaimer;
use Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...
next prev parent reply other threads:[~1999-11-19 0:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-11-19 0:00 null range from 1 element discrete type Duncan Sands
1999-11-19 0:00 ` Robert I. Eachus [this message]
1999-11-22 0:00 ` Robert Dewar
1999-11-25 0:00 ` Niklas Holsti
1999-11-22 0:00 ` Robert A Duff
1999-11-22 0:00 ` Robert Dewar
1999-11-19 0:00 ` Matthew Heaney
1999-11-19 0:00 ` Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox