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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.66.222.41 with SMTP id qj9mr23228430pac.30.1437899376006; Sun, 26 Jul 2015 01:29:36 -0700 (PDT) X-Received: by 10.140.101.243 with SMTP id u106mr413604qge.27.1437899375768; Sun, 26 Jul 2015 01:29:35 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!f3no2992667igg.0!news-out.google.com!b31ni699qge.0!nntp.google.com!69no1989765qgl.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 26 Jul 2015 01:29:35 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=81.203.145.32; posting-account=AFCLjAoAAABJAOf_HjgEEEi3ty-lG5m2 NNTP-Posting-Host: 81.203.145.32 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: How do you specialize a generic function from a nested function? From: EGarrulo Injection-Date: Sun, 26 Jul 2015 08:29:35 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:27009 Date: 2015-07-26T01:29:35-07:00 List-Id: I am trying to write a generic predicate that negates a supplied predicate.= The generic predicate compiles, but the compilation of client code fails = with "generic subprogram cannot be called" (because the client code supplie= s a nested predicate, I suppose). Here is the code (see the comment in the= last file). ------------- negate.ads ------------------ generic type Value_Type is private; with function Predicate (Value : Value_Type) return Boolean; -- I have also tried with: -- Predicate : access function (Value : Value_Type) return Boolean; function Negate (Value : Value_Type) return Boolean; ------------- negate.adb ------------------ function Negate (Value : Value_Type) return Boolean is begin return not Predicate (Value); end Negate; ------------- test.adb ------------------ with Negate; procedure test is function Is_Zero (Value: Integer) return Boolean is (Value =3D 0); Is_Not_Zero : access function (Value: Integer) return Boolean=20 :=3D Negate(Integer, Is_Zero'Access); -- <<=3D=3D ##### ERROR HERE ##### begin null; end test; -------------------------------------- What is wrong? And -- in any case -- could the code be simplified? Thank = you.