comp.lang.ada
 help / color / mirror / Atom feed
* Dynamic_Predicate  with a generic
@ 2012-10-31  3:58 Bill Findlay
  2012-10-31  4:31 ` Shark8
  0 siblings, 1 reply; 2+ messages in thread
From: Bill Findlay @ 2012-10-31  3:58 UTC (permalink / 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;





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

end of thread, other threads:[~2012-10-31  4:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-31  3:58 Dynamic_Predicate with a generic Bill Findlay
2012-10-31  4:31 ` Shark8

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