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-Received: by 2002:ac8:339b:: with SMTP id c27mr28478531qtb.210.1591721052294; Tue, 09 Jun 2020 09:44:12 -0700 (PDT) X-Received: by 2002:a9d:58c4:: with SMTP id s4mr21619686oth.240.1591721052036; Tue, 09 Jun 2020 09:44:12 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 9 Jun 2020 09:44:11 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=146.5.2.231; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 146.5.2.231 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <2bbd5c7c-78da-4127-b85a-eeb3f9651456o@googlegroups.com> Subject: Re: generic with function procedure From: Shark8 Injection-Date: Tue, 09 Jun 2020 16:44:12 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:59024 Date: 2020-06-09T09:44:11-07:00 List-Id: On Friday, June 5, 2020 at 8:35:34 AM UTC-6, Gilbert Gosseyn wrote: >=20 > the message is: no visible subprogram matches the specification for "g" > no visible subprogram matches the specificatio= n for "h" Well, first, let's look at some generic code: Generic Type Element is private; Type Index is (<>); Type Vector is Array( Index range <> ) of Element; Zero : Element; with Function "+"( Left, Right : Element ) return Element is <>; Function Generic_Sum( Input : Vector ) return Element; Function Generic_Sum( Input : Vector ) return Element is Return Result : Element :=3D Zero do For Item of Input Loop Result:=3D Result + Item; End Loop; End Return; End Generic_Sum; Now, if we say something like: Package Example_1 is Type X is private; Type Y is range 1..7; Type Vector is Array(Y range <>) of X; Function "+"( Right : Vector ) return Element; Default : Constant X; Private Function Sum is new Generic_Sum(X,Y,Vector, Zero =3D> Default, others = =3D> <>); Type X is range 0..15; -- 4-bits. Function "+"( Right : Vector ) return Element renames Sum; Default : Constant X :=3D 0; End Example_1; ...doesn't work. Why? Well, for one, the point where you're trying to instantiate Generic_Sum int= o Sum, even though the parameter (X) matches the formal parameter, at this = point in the code the only thing we know is that it's a private type... it = doesn't have a "+" function that it can see, and so it will tell you that t= here's nothing to match with function "+". Swapping the "function Sum is" and "type X is" lines would solve that probl= em, but there *might* be another, similar one: the constant (Default) hasn'= t yet been assigned a value and so the instantiation might fail. (I'd have = to re-read the ARM,) In your post the line "procedure nm is new denm(f=3D>f1,g=3D>g1,h=3D>h1);" = is analogous to the situation above, albeit slightly different: you're expl= icitly specifying that subprograms "g1" and "h1" are to be respectively ass= ociated with parameters "g" and "h" -- this is all well and good, and the c= ompiler has caught two mistakes for you: =E2=80=94 no visible subprogram matches the specification for "g" =E2=80=94 no visible subprogram matches the specification for "h"=20 So it's telling you that of all the functions "g1" that it sees at the poin= t of instantiation, none match the generic's specification of "function g(j= : Integer; v : Real_Vector) return Real;" (and the same for "h".) Now, at this point the compiler cannot do anything more: this is the realm = where only the human programmer can tell what to do: =E2=80=94 Is it a copy and paste-error creating the functions "g" and "h"? = (Were they declared in the form of "f" which is "(v : Real_Vector) return R= eal;" instead of "(j : Integer; v : Real_Vector) return Real;"?) =E2=80=94 Did you perhaps mean to make the formal parameters of denm, "g" a= nd "h", to be "(v : Real_Vector) return Real;" instead of "(j : Integer; v = : Real_Vector) return Real;"? (Perhaps being interrupted while refactoring = it, and it's stuck in a form intermediate between what you had and what you= want.) =E2=80=94 Did you forget to make a "g1" and "h1"?