|There is nothing like non-consecutive ranges built into the language.
However, you could define a private type and a "convert_from_int"
function which did an arbitrarily complicated test before
agreeing to convert the integer to a value of the private type.
You could "inline" this function to get roughly the same
performance as if the capability were supported directly
through some special syntax.
If you had a general requirement for types like this, you
could go so far as to write a generic package to be used
for defining such "holey" types, with generic formal parameters
indicating the gap(s) in the range. E.g.:
type Underlying_Type is (<>);
First, Gap_First, Gap_Last, Last : Underlying_Type;
package Holey_Types is
type Holey is private;
function Make_Holey(Val : Underlying_Type) return Holey;
function Val(H : Holey) return Underlying_Type;
pragma Inline(Make_Holey, Val);
type Holey is new Underlying_Type range First .. Last;
package body Holey_Types is
function Make_Holey(Val : Underlying_Type) return Holey is
if Val in Gap_First .. Gap_Last then
return Holey(Val); -- Constraint_Error if not in First .. Last
function Val(H : Holey) return Underlying_Type is