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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ae928372f6e8af2 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!uninett.no!news.banetele.no!news.hacking.dk!pnx.dk!not-for-mail From: Jacob Sparre Andersen Newsgroups: comp.lang.ada Subject: Problem with generic parameter Date: 22 Jun 2005 12:21:10 +0200 Organization: hacking.dk - Doing fun stuff with open source Sender: sparre@hugin.crs4.it Message-ID: NNTP-Posting-Host: hugin.crs4.it Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: xyzzy.adsl.dk 1119435982 28273 156.148.71.67 (22 Jun 2005 10:26:22 GMT) X-Complaints-To: usenet@news.hacking.dk NNTP-Posting-Date: Wed, 22 Jun 2005 10:26:22 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 Xref: g2news1.google.com comp.lang.ada:11546 Date: 2005-06-22T12:21:10+02:00 List-Id: When I try to compile the program included below (cut down version of a test program) GNAT 3.15p reports: ----- Compiling: demo.adb (source file time stamp: 2005-06-22 10:10:41) 16. Measurement_Array => Measurement_Array); | >>> component subtype of actual does not match that of formal "Measurement_Array" >>> instantiation abandoned 20 lines: 2 errors ----- I can't see _how_ it doesn't match. Can somebody figure out what I'm doing wrong? And maybe even suggest me an elegant solution to the problem? The reason I have Measurement_Array as a generic parameter is that I also use it elsewhere, and that I may want to work with differently indexed measurement arrays. Does it - despite that - make more sense to declare the types "Measurement" and "Measurement_Array" together? /Jacob ------------------------------------------------------------------------------ -- Source code: with Generic_Root; with Generic_Root.Child; procedure Demo is type Scalar is digits 15; package Measurements is new Generic_Root (Scalar => Scalar); type Measurement_Array is array (Positive range <>) of Measurements.Measurement; package Measurement_Text_IO is new Measurements.Child (Indices => Positive, Measurement_Array => Measurement_Array); begin null; end Demo; generic type Scalar is digits <>; package Generic_Root is --------------------------------------------------------------------------- -- type Limit: type Limit is (Below, Exact, Above, Undefined); --------------------------------------------------------------------------- -- type Measurement: type Measurement (As : Limit := Exact) is record case As is when Below | Exact | Above => Value : Scalar; when Undefined => null; end case; end record; --------------------------------------------------------------------------- end Generic_Root; with Ada.Text_IO; generic type Indices is (<>); type Measurement_Array is array (Indices range <>) of Measurement; package Generic_Root.Child is end Generic_Root.Child;