Why is Dynamic_Predicate not working?

167 views Asked by At

I started to learn Ada yesterday but I don't really understand the Dynamic_Predicate'aspect. when declaring:

type evenInt is new Integer
 with Dynamic_Predicate => evenInt mod 2 = 0;

Why is it still possible to:

anOddNum : evenInt := 7;

since:

Dynamic_Predicate => evenInt mod 2 = 0 

forbids to declare odd numbers?

1

There are 1 answers

2
egilhh On BEST ANSWER

You need to compile with assertions enabled (-gnata)