comp.lang.ada
 help / color / mirror / Atom feed
* Ambiguity in Ada LRM about private types and type conversions
@ 1986-11-24 21:26 Jonathan P. Biggar
  0 siblings, 0 replies; only message in thread
From: Jonathan P. Biggar @ 1986-11-24 21:26 UTC (permalink / raw)


The following code fragment demonstrates an ambiguity in the Ada Language
Reference Manual:

package EXPORT is
    type T is private;
private
    type T is range 0..100;
end EXPORT;

with EXPORT;
use  EXPORT;
procedure FOO is
    A: INTEGER;
    B: T;
begin
    A := INTEGER(B);
    B := T(A);
end FOO;

Upon examination of this code, one would expect that a compiler must reject
this, because to allow it would mean abrogating the data integrety
mechanism provided by private types.  If allowed, a user can convert
to and from a private type at will.

The LRM does not explicitly disallow this however.  In 7.4.2(1),
the operations declared by a private type declaration include
explicit conversions.  The intention seems to be to allow explicit
conversion between the private type and any types derived from that
private type.  It also seems to allow the type conversions in the above
code.

There needs to be a statement in the LRM to explicitly disallow explicit
conversions from a private type to types defined compatible to the private
type's implementation by 4.6 cases a, b or c.

Jon Biggar
jonab@SDC-CAMARILLO.ARPA
sdcrdcf!jonab

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1986-11-24 21:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1986-11-24 21:26 Ambiguity in Ada LRM about private types and type conversions Jonathan P. Biggar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox