comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Disagreement between GNAT and Cohen?
Date: Thu, 13 Jun 2002 01:52:59 GMT
Date: 2002-06-13T01:52:59+00:00	[thread overview]
Message-ID: <wcchek8osg4.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 3D05A559.9020502@golter.demon.co.uk

Andrew Hoddinott <andrew@golter.demon.co.uk> writes:

> I'm still puzzled though. Cohen's actual example (p. 696-7) is:
> 
> generic
>    type Element_Type is (<>);
> package Generic_Discrete_Sets is
>    type Set_Type is private;
>    function Union (Set_1, Set_2  : Set_Type ) return Set_Type;
>    --  ... more functions and types
> private
>    type Set_Type is array (Element_Type) of Boolean;
> end Generic_Discrete_Sets;
> 
> package body Generic_Discrete_Sets is
>    function Union (Set_1, Set_2 : Set_Type) return Set_Type
>       renames "or";
>    --  ... more function bodies
> end Generic_Discrete_Sets;

This code looks wrong to me.  I don't understand the GNAT error message,
though.

> generating the errors:
> generic_discrete_sets.adb:2:04: not subtype conformant with declaration
> in package Standard
> generic_discrete_sets.adb:2:04: return type does not match
> 
> He specifically draws attention to the package body using "the versions
> of the logical operators 'and', 'or', and 'not' that apply component by
> component to one-dimensional arrays of Boolean values", and bases an
> exercise (15.3) around the example too.
> 
> Is he just making this up?

Perhaps Norm Cohen compiled the code with an early version of GNAT that
didn't check the rule.  I believe the GNAT implementation generates a
dummy body for a renaming-as-body, so it would work just fine.

What Cohen is trying to do is perfectly reasonable -- the rule is not
there for semantic reasons, but to ease a certain implementation
technique.  In hindsight, I think the rule is misguided.

>... Or is there some way that the frozen-ness of
> the intrinsic logical operators can vary between compilers so that this
> example sometimes works?

No, all compilers should agree on this.

>... And the intrinsic not getting an explicit
> mention in the error message in this slightly more complex case is
> because ... ?

Beats me.

> Sorry. Since I know how to work around the problem, I should probably
> just shut up and go on to the next exercise, but ... ;-)

Nothing wrong with trying to understand the language.  ;-)

- Bob



  reply	other threads:[~2002-06-13  1:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-11  0:33 Disagreement between GNAT and Cohen? Andrew Hoddinott
2002-06-11  1:00 ` Robert A Duff
2002-06-11  7:23   ` Andrew Hoddinott
2002-06-13  1:52     ` Robert A Duff [this message]
2002-06-11  1:12 ` Preben Randhol
replies disabled

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