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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Ada.Numerics.Long_Real_Arrays Date: Thu, 26 Jan 2017 14:52:56 +0000 Organization: A noiseless patient Spider Message-ID: References: <5a19787c-a11c-470e-8cef-2c5dc4897bf7@googlegroups.com> <23d8f4a2-867e-4fae-b056-952039ab0732@googlegroups.com> <88df1d97-6f7a-410f-8d1b-fa1d3ee44ea7@googlegroups.com> <712de11c-94ae-4703-8cfb-9ff2decccaeb@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="f183377ec578a4cf1731a567b851ffac"; logging-data="1744"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+qTj2y06RuzIocn+Ahjw+jKEZijKVfgMg=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (darwin) Cancel-Lock: sha1:2HsM0OHHXfF/88Tn2E+72UdetsQ= sha1:xnOFi6M78slFuPge0iLB/SXu92E= Xref: news.eternal-september.org comp.lang.ada:33178 Date: 2017-01-26T14:52:56+00:00 List-Id: This will compile, and preserve visibility of the underlying Vectors. I'm not sure whether one could get something less clumsy by using Ada.Containers.Indefinite_Vectors to hold the R_Vectors. with Ada.Numerics.Long_Real_Arrays; generic Np : Positive; package Nm_G is subtype R_Vector is Ada.Numerics.Long_Real_Arrays.Real_Vector (1 .. Np); type R_Matrix is array (1 .. Np + 1) of R_Vector; end Nm_G; with Nm_G; package Nm is -- I assume there's more than just Fnm here; if not, Fnm could be a -- library-level generic subprogram. -- -- Of course, if there _is_ more than just Fnm, it's likely the -- other components will also need to know which instantiation of -- Nm_G they have to deal with, and the 'with package' bit would -- need to be placed on the Nm (which itself has to be generic). generic -- This generic needs to know which instantiation of Nm_G it is -- to deal with. with package Nm_I is new Nm_G (<>); -- Now we know what type the parameter of the actual F has to -- be. with function F (R : Nm_I.R_Vector) return Long_Float; procedure Fnm (P : in out Nm_I.R_Matrix); end Nm; package body Nm is procedure Fnm (P : in out Nm_I.R_Matrix) is begin null; end Fnm; end Nm; with Nm; with Nm_G; procedure Test_Nm is package Nm_Inst is new Nm_G (Np => 2); function Actual_F (R : Nm_Inst.R_Vector) return Long_Float is (42.0); procedure Actual_Fnm is new Nm.Fnm (Nm_I => Nm_Inst, F => Actual_F); P : Nm_Inst.R_Matrix := ((1.0, 2.0), (3.0, 4.0), (5.0, 6.0)); begin Actual_Fnm (P); end Test_Nm;