comp.lang.ada
 help / color / mirror / Atom feed
From: stt@houdini.camb.inmet.com (Tucker Taft)
Subject: Re: statically compatible access discriminants in derivation
Date: 1998/01/17
Date: 1998-01-17T00:00:00+00:00	[thread overview]
Message-ID: <EMxyFC.48z.0.-s@inmet.camb.inmet.com> (raw)
In-Reply-To: 69gucb$l9k$1@uuneo.neosoft.com


Pat Rogers (progers@acm.org) wrote:

: ...
: with device_instance;
: with unit_if;
: package unit_instance is
:   type object( board : access device_instance.object'class ) is
:     new unit_if.object( board ) with null record;
:   procedure foo( this : in out object );
: end unit_instance;

: That way I can directly reference X within foo:

: package body unit_instance is
:   procedure foo( this : in out object ) is
:   begin
:     this.board.x := 0;
:   end foo;
: end unit_instance;

: As I read the RM, it seems that 3.7(15) requires them to statically match,
                                   "compatible", not "match" ---------^^^^^
: and 4.9.1 says that they can not.  Is there a way around this?

Reread 3.7(15).  It uses the term "statically compatible" not "statically
match"  Because anonymous access subtypes are always unconstrained,
there is no problem of compatibility, presuming the expression used
in the constraint is convertible to the anonymous access type (which 
it is).  

: As I mentioned, I could just inherit the discriminant 'board' designating
: device_if.object'class, and convert to device_instance.object'class, but
: would rather have it checked when the objects are declared.

: Any ideas?

The code above should compile.  Is it being rejected by your
favorite Ada compiler?  You might post the error messages you
are receiving.  Perhaps the real problem is elsewhere.

--
-Tucker Taft   stt@inmet.com   http://www.inmet.com/~stt/
Intermetrics, Inc.  Burlington, MA  USA




      parent reply	other threads:[~1998-01-17  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-01-13  0:00 statically compatible access discriminants in derivation Pat Rogers
1998-01-16  0:00 ` Nick Roberts
1998-01-17  0:00 ` Tucker Taft [this message]
replies disabled

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