comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pogner.demon.co.uk>
Subject: Re: Constraints?
Date: 1998/12/25
Date: 1998-12-25T00:00:00+00:00	[thread overview]
Message-ID: <x7vhfukit5q.fsf@pogner.demon.co.uk> (raw)
In-Reply-To: 75ntvd$bue$1@tsunami.traveller.com

"David C. Hoos, Sr." <david.c.hoos.sr@ada95.com> writes:

> Simon Wright wrote in message ...
> >package foo is
> >    type t is abstract tagged null record;
> >    type i (f : access t'class) is abstract tagged limited null record;
> >    type n is new t with null record;
> >    type r (f : access n) is new i (f) with null record;
> >    -- OA says foo.ads: Error: line 5 col 37 LRM:3.7(15), Subtype of
> >    -- discriminant must be statically compatible with subtype of the
> >    -- corresponding parent discriminant
> >end foo;
> The real problem is a violation of LRM:3.7(13).
> Both compilers will accept the code below.
> package foo is
>     type t is abstract tagged null record;
>     type i (f : access t'class) is abstract tagged limited null record;
>     type n is new t with null record;
>     type a_n is access all n'class;
>     type r (f : a_n) is new i (f) with null record;
> end foo;

Thanks for that. I don't quite see what (13) has to do with it?

I think I always get frightened by this sort of thing, cos clearly
(!!) the code I need (which is also acceptable to both compilers) is

package foo is
    type t is abstract tagged null record;
    type i (f : access t'class) is abstract tagged limited null record;
    type n is new t with null record;
    type r (f : access n'class) is new i (f) with null record;
end foo;

Referring to my original, Robert Dewar wrote:

> This is definitely invalid. GNAT says:
> 
> foo.ads:5:13: subtype must be compatible with parent
> discriminant

... so I won't need to report the fact that 3.11B _doesn't_ detect the
error, then!




  reply	other threads:[~1998-12-25  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-12-22  0:00 Constraints? Simon Wright
1998-12-22  0:00 ` Constraints? David C. Hoos, Sr.
1998-12-25  0:00   ` Simon Wright [this message]
1998-12-25  0:00     ` Constraints? dewar
1998-12-30  0:00   ` Constraints? Steve Todd
1998-12-23  0:00 ` Constraints? dewar
replies disabled

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