From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5948949183cbd10c X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.66.75.39 with SMTP id z7mr12482274pav.26.1351657886523; Tue, 30 Oct 2012 21:31:26 -0700 (PDT) Received: by 10.68.253.129 with SMTP id aa1mr10999861pbd.17.1351657886496; Tue, 30 Oct 2012 21:31:26 -0700 (PDT) Path: 6ni51771pbd.1!nntp.google.com!kt20no26389270pbb.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 30 Oct 2012 21:31:26 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.20.190.126; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 69.20.190.126 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <8cb762ea-3010-4351-b5d6-573b4299c95f@googlegroups.com> Subject: Re: Dynamic_Predicate with a generic From: Shark8 Injection-Date: Wed, 31 Oct 2012 04:31:26 +0000 Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-10-30T21:31:26-07:00 List-Id: > > > > ==============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? Maybe nothing, I recently found two bugs one where declare item : a_type := ...; begin Operation( New a_type'( item) ); end gave results you would expect from using 'unchecked_access. and another where LRM 6.5 isn't implemented (Aliased extended returns). I put the package into the declaration area of a procedure and it compiled fine. generic type integral is range <>; type unsigned_integral is mod <>; package prime_numbers with Elaborate_Body is 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); end prime_numbers; package body prime_numbers is function is_prime (nr : integral) return Boolean is begin Return Result : Boolean := Integer(nr) in positive do if Result then case pos_integral(nr) is when 1 | 2 | 3 => null; when Others => declare subtype Mod_Search is integral range 2..nr-2; begin for Index in mod_search loop if nr mod Index = 0 then Result := False; return; end if; end loop; end; end case; end if; end return; end is_prime; end prime_numbers; Type mod_13 is mod 13; Package P is new Prime_numbers( integral => Integer, unsigned_integral => mod_13);