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: Q: Trouble creating array and discriminated type Date: Mon, 23 Jan 2017 08:19:21 +0000 Organization: A noiseless patient Spider Message-ID: References: <83409c51-59d3-4205-9eeb-5467de09f069@googlegroups.com> <3b436d6a-7704-47cf-8f6f-d974771bea63@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="dc6326e3c772003b4b4215f13bb0aedc"; logging-data="13213"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18H0h7jR5MPcFRLHgdPe/S8GzFhICJZMjE=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (darwin) Cancel-Lock: sha1:hGycHC9TomAK5Bal7kjc3vOpzrg= sha1:r5WNfF4LIbo6MTSPUYR4gDYmB1U= Xref: news.eternal-september.org comp.lang.ada:33126 Date: 2017-01-23T08:19:21+00:00 List-Id: "G.B." writes: > Defaults for discriminants of tagged types would not be permitted, > only if objects of the type can not have their discriminants changed > after creation (tagged limited). The reason is stated in AARM 3.7(9.*) > and it seems to say "It's complicated". > > The paragraph suggest that for some use cases, one can declare a > subtype that sets the discriminants to default values. IIUC, these > subtypes can then be used in derivations also. Not sure about use in derivations, but I have generic Maximum_Size : Positive; package BC.Containers.Collections.Bounded is type Unconstrained_Collection (Maximum_Size : Positive) is new Abstract_Collection with private; subtype Collection is Unconstrained_Collection (Maximum_Size => Maximum_Size); I've never been happy about Maximum_Size there, but that's the sort of thing that happens when you already have a published interface that you're reluctant to change!