comp.lang.ada
 help / color / mirror / Atom feed
From: Bill Findlay <yaldnif.w@blueyonder.co.uk>
Subject: Dynamic_Predicate  with a generic
Date: Wed, 31 Oct 2012 03:58:40 +0000
Date: 2012-10-31T03:58:40+00:00	[thread overview]
Message-ID: <CCB65270.20246%yaldnif.w@blueyonder.co.uk> (raw)

The following code compiles:
> 
>    type integral          is new Integer;
>    type unsigned_integral is mod 2**32;
> 
>    subtype nat_integral is integral range 0 .. integral'Last;
>    subtype pos_integral is integral range 1 .. integral'Last;
> 
>    -- returns True iff nr is a prime number
>    function is_prime (nr : integral) return Boolean;
> 
>    subtype prime_number is integral
>       with Dynamic_Predicate => is_prime(prime_number);
> 

But if the types integral and unsigned_integral are given by generic type
parameters, thus:

> generic
>    type integral          is range <>;
>    type unsigned_integral is mod <>;
> package prime_numbers is
> 
>     pragma Elaborate_Body;
> 
>    subtype nat_integral is integral range 0 .. integral'Last;
>    subtype pos_integral is integral range 1 .. integral'Last;
> 
>    -- returns True iff nr is a prime number
>    function is_prime (nr : integral) return Boolean;
> 
>    subtype prime_number is integral
>       with Dynamic_Predicate => is_prime(prime_number);

I get the error message:

> 
> ==============Error messages for source file: prime_numbers.ads
>     20.       with Dynamic_Predicate => is_prime(prime_number);
>                                                  |
>>>> invalid use of subtype mark in expression or call

What am I missing?

-- 
Bill Findlay
with blueyonder.co.uk;
use  surname & forename;





             reply	other threads:[~2012-10-31  3:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-31  3:58 Bill Findlay [this message]
2012-10-31  4:31 ` Dynamic_Predicate with a generic Shark8
replies disabled

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