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,cea03ed275aa3d28 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns13feed!worldnet.att.net!attbi_s71.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" Organization: jrcarter at acm dot org User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Question about generics. References: <7Q2qg.812592$084.507058@attbi_s22> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 12.201.97.176 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s71 1151957001 12.201.97.176 (Mon, 03 Jul 2006 20:03:21 GMT) NNTP-Posting-Date: Mon, 03 Jul 2006 20:03:21 GMT Date: Mon, 03 Jul 2006 20:03:21 GMT Xref: g2news2.google.com comp.lang.ada:5441 Date: 2006-07-03T20:03:21+00:00 List-Id: Peter C. Chapin wrote: > > Why not a compile time error when the instantiation is attempted? Because the legality of a generic unit is determined when the generic is compiled, not when it is instantiated. That the generic formal of Size allows non-positive values is yet another reason this specific example would be illegal, even if Size were static. > Yes. However, this means at the point of instantiation I have to do > something like > > type Dummy_Type is mod 8; > package Fizzle is new Xyzzy(Index => Dummy_Type); > > The Dummy_Type will never be used in the context of the instantiation; > it only exists to pass size information into the generic package. That > seems pretty counter-intuitive and awkward. I guess I was hoping Ada > would have a nicer solution... generic parameters that are named numbers > or something. I find this hard to accept. The reason to declare a visible type in the generic is so that the client can use the type from an instantiation to call operations of the type provided by the generic. -- Jeff Carter "Now go away or I shall taunt you a second time." Monty Python & the Holy Grail 07