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!.POSTED!not-for-mail From: "Alejandro R. Mosteo" Newsgroups: comp.lang.ada Subject: Re: Unknown constraints and type composition Date: Fri, 15 Jun 2018 11:37:46 +0200 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 15 Jun 2018 09:37:47 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="28f9812d2e4a4d571e566a6a5e6288c5"; logging-data="16185"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/wiFdoz7XcDll8jFAag9iP" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 Cancel-Lock: sha1:rzdamI70OyqH+RFWKoNtzJMrvoQ= In-Reply-To: Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:53119 Date: 2018-06-15T11:37:46+02:00 List-Id: On 14/06/2018 17:37, Alejandro R. Mosteo wrote: Thanks everyone for your comments. I think every approach was different and had some good food for thought. It seems things where more or less as I figured but seeing how different people goes about it reassures me. Alex. > I think I have read somewhere that types with unknown constraints are a > good way of ensuring you (or your users) don't end with uninitialized > values: > > types Whatever (<>) is [limited] private; > > function Create return Whatever; > > This seems nice at first sight but when these types have any likelihood > of ending as members of another type you will hit the "unconstrained > member" problem. > > A workaround then is to use a Indefinite_Holder, but that's an imposition > on your clients (ugly). If your type is furthermore limited, then you > must use pointers and consider providing controlledness and deallocation > in the enclosing type (uglier). > > Right now I'm on the point of a new design where I have many interrelated > types that require initialization calls (it's a C binding). And, as > always, I'm unsure of the way to go, or if I'm missing another technique > without shortcomings. Your thoughts if you have any on this issue are > much appreciated. > > Alex.