comp.lang.ada
 help / color / mirror / Atom feed
* Language lawyer question: Equality on 'Access attributes
@ 2004-01-08  2:05 Adam Beneschan
  2004-01-08  7:47 ` Robert I. Eachus
       [not found] ` <hmfvc1-f73.ln1@beastie.ix.netcom.com>
  0 siblings, 2 replies; 40+ messages in thread
From: Adam Beneschan @ 2004-01-08  2:05 UTC (permalink / raw)


Given this code:

package Pak1 is
    type Ptr1 is access all Integer;
    X : aliased Integer;
    Y : aliased Integer;
    B : Boolean := X'Access = Y'Access;
end Pak1;

GNAT gives me this error: "two access attributes cannot be compared
directly / they must be converted to an explicit type for comparison".

But I can't figure out why this should be an error.  Based on my
understanding of the language: The compiler needs to figure out
whether the interpretation of "X'Access = Y'Access" in which "="
denotes the equality operator implicitly defined for Ptr1 is an
acceptable interpretation (8.6(10-14)).  For a call to this "="
function, 6.4.1(3) says that the expected type for each argument is
Ptr1.  According to 3.10.2, X'Access and Y'Access do not have a
particular type out of context, but rather the types of these
constructs are determined by the expected type; when determining
whether these can be used as parameters to "=", the expected type is
Ptr1, and clearly it's legal to use X'Access or Y'Access in a
construct where the expected type is Ptr1.  So as far as I can tell,
this *is* an acceptable interpretation; and since there's only one "="
visible whose parameter types are access-to-integer, the requirement
of 8.6(30) is met that there be exactly one acceptable interpretation
of the function call, and thus this should be legal.  (If there were a
second access type, "type Ptr2 is access all integer", then B's
initialization expression would be ambiguous, since there would then
be two visible "=" operators for which the interpretation would be
acceptable.)  Note that the modified version of 3.10.2(2) in
AI95-00235 doesn't affect this analysis.

Is this analysis correct?  If not, where did I go wrong?  If I'm wrong
and GNAT is right, then could someone explain to me just how 8.6 and
3.10.2 are to be applied together when an 'Access attribute is used? 
The wording of the GNAT error message makes it appear to me that
GNAT's authors interpreted the RM as prohibiting this construct---but
I can't figure out where in the RM this would be prohibited.

                                     -- thanks, Adam



^ permalink raw reply	[flat|nested] 40+ messages in thread
* Re: Language lawyer question: Equality on 'Access attributes
@ 2004-01-09  5:48 christoph.grein
  0 siblings, 0 replies; 40+ messages in thread
From: christoph.grein @ 2004-01-09  5:48 UTC (permalink / raw)
  To: comp.lang.ada

RM 3.10.2(2) ...Access...the expected type shall be a single access type...

RM 8.6(27) When the expected type...is required to be a single type...shall be 
determinable solely from the context...shall not be the operand of a 
type_conversion.

Therefore:

	B: Boolean :=    X'Access  = Y'Access;  -- illegal
	B: Boolean := T (X'Access) = Y'Access;  -- illegal
	B: Boolean := T'(X'Access) = Y'Access;  --   legal



^ permalink raw reply	[flat|nested] 40+ messages in thread
* Re: Language lawyer question: Equality on 'Access attributes
@ 2004-01-09  6:03 christoph.grein
  0 siblings, 0 replies; 40+ messages in thread
From: christoph.grein @ 2004-01-09  6:03 UTC (permalink / raw)
  To: comp.lang.ada, adam

> original post.  The question is, what should happen when only one such
> "=" operator is a possibility.

AARM 8.6(27.a) ...The resason for these rules is that the compiler will not have 
to search "everywhere"...



^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2004-01-12  5:16 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-08  2:05 Language lawyer question: Equality on 'Access attributes Adam Beneschan
2004-01-08  7:47 ` Robert I. Eachus
2004-01-08 11:07   ` Dmitry A. Kazakov
2004-01-08 17:18   ` Adam Beneschan
2004-01-08 18:04     ` Robert A Duff
2004-01-08 18:31       ` Ze Administrator
2004-01-08 21:04         ` Robert A Duff
2004-01-09  4:02           ` Ze Administrator
2004-01-09 23:02             ` Robert A Duff
2004-01-10  2:56               ` Ze Administrator
2004-01-09  4:06           ` Ze Administrator
2004-01-09 23:05             ` Robert A Duff
2004-01-10  3:03               ` Ze Administrator
2004-01-10 13:47                 ` Marin David Condic
2004-01-10  7:19               ` Robert I. Eachus
2004-01-10 19:09                 ` Robert A Duff
2004-01-11 14:27                   ` Robert I. Eachus
2004-01-11 21:42                     ` Ze Administrator
2004-01-12  5:16                       ` Robert I. Eachus
2004-01-09  1:28         ` Adam Beneschan
2004-01-09  4:10           ` Ze Administrator
2004-01-09 11:27             ` Dmitry A. Kazakov
2004-01-09 23:09               ` Robert A Duff
2004-01-10 11:56                 ` Dmitry A. Kazakov
2004-01-10 17:08                   ` Robert I. Eachus
2004-01-10 18:40                   ` Robert A Duff
2004-01-09 23:08             ` Robert A Duff
2004-01-10  7:39               ` Robert I. Eachus
2004-01-08 20:36       ` tmoran
2004-01-08 21:06         ` Robert A Duff
2004-01-09  0:27       ` Randy Brukardt
2004-01-09  1:23       ` Adam Beneschan
2004-01-09  1:38         ` Robert A Duff
2004-01-09  6:16       ` Robert I. Eachus
2004-01-09 23:27         ` Randy Brukardt
2004-01-10 16:37           ` Robert I. Eachus
     [not found] ` <hmfvc1-f73.ln1@beastie.ix.netcom.com>
     [not found]   ` <l7v1d1-n33.ln1@beastie.ix.netcom.com>
2004-01-09 23:19     ` Robert A Duff
2004-01-09 23:21     ` Randy Brukardt
  -- strict thread matches above, loose matches on Subject: below --
2004-01-09  5:48 christoph.grein
2004-01-09  6:03 christoph.grein

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