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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,60d3b03058ac88c4,start X-Google-Attributes: gid103376,public From: Dale Stanbrough Subject: Why unknown discriminants for private types? Date: 1996/04/11 Message-ID: <4khqh6$33e@goanna.cs.rmit.edu.au>#1/1 X-Deja-AN: 146844530 distribution: world content-type: text/plain; charset=ISO-8859-1 x-xxmessage-id: organization: Royal Melbourne Institute of Technology mime-version: 1.0 newsgroups: comp.lang.ada Date: 1996-04-11T00:00:00+00:00 List-Id: In a previous question on how to force initialization of objects (c.f. constructors in C++) I have been pointed to using unknown discriminants on private types. >From the rationale I found... "A private type can now be marked as having an unknown number of discriminants thus type T(<>) is private; The main impact of this is that the partial view does not allow uninitialized objects to be declared. If the partial view is also limited then objects cannot be declared at all (since they cannot be initialized). The gives the writer of an abstraction rather more control over the use of the abstraction." My problem with this is that it seems a rather obscure method to enforce initialization, compared to a specific pragma. For example... type T is private; pragma enforce_initialization(T); which seems much more readable. As well unknown descriminants precludes the writing of some types, as type T above is (or at least it's partial view) is unconstrained. The following is thus illegal... package A is type T(<>) is private; type List is array(1..10) of T; private ... end A; As well a pragma enforce_initialization could be applied to non private objects. Certainly such a pragma could be added to any compiler without affecting the portability of programs using it. Any comments? Dale