From: Dale Stanbrough <dale@goanna.cs.rmit.EDU.AU>
Subject: Why unknown discriminants for private types?
Date: 1996/04/11
Date: 1996-04-11T00:00:00+00:00 [thread overview]
Message-ID: <4khqh6$33e@goanna.cs.rmit.edu.au> (raw)
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
reply other threads:[~1996-04-11 0:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox