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: Unknown constraints and type composition Date: Thu, 14 Jun 2018 17:37:26 +0200 Organization: A noiseless patient Spider Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 14 Jun 2018 15:37:27 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="ce67c4be68632317940332cc3f331785"; logging-data="13195"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18CIpCI02iiAENH1q+xCvPi" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 Cancel-Lock: sha1:E06/fcw3Rn7wc7NMryo4tVn5sxI= Content-Language: en-US X-Mozilla-News-Host: news://news.eternal-september.org:119 Xref: reader02.eternal-september.org comp.lang.ada:53101 Date: 2018-06-14T17:37:26+02:00 List-Id: 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.