comp.lang.ada
 help / color / mirror / Atom feed
* Is assignment available for access parameters?
@ 1997-03-26  0:00 Matthew Heaney
  1997-03-26  0:00 ` Samuel Tardieu
  0 siblings, 1 reply; 2+ messages in thread
From: Matthew Heaney @ 1997-03-26  0:00 UTC (permalink / raw)




Is assignment of an access parameter to an object of a named (general)
access type legal?  The code below compiles under my compiler (GNAT), but
not on others (Rational, Aonix).  Who is correct?

My expectation is that the assignment be illegal, because the type is
anonymous.  This would be analogous to the rule that types that have an
access discriminant must be limited.  (Of course, with a type conversion,
then the assignment can be made legal.)

But I'm not sure.  RM95 5.2 (4) states that the "expected type for the
expression [on the RHS] is the type of the target."  Is an access parameter
implicitly converted to the target type?

-- STX
package P is

   type T is tagged null record;

   type TA is access all T'Class;

end;


with P;
procedure Test_P is

   procedure Proc (OA : access P.T) is
      OTA : P.TA := OA;  -- ???
   begin
      null;
   end;

begin

   null;

end;
-- ETX

Matt

--------------------------------------------------------------------
Matthew Heaney
Software Development Consultant
<mailto:matthew_heaney@acm.org>
(818) 985-1271




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

* Re: Is assignment available for access parameters?
  1997-03-26  0:00 Is assignment available for access parameters? Matthew Heaney
@ 1997-03-26  0:00 ` Samuel Tardieu
  0 siblings, 0 replies; 2+ messages in thread
From: Samuel Tardieu @ 1997-03-26  0:00 UTC (permalink / raw)
  To: Matthew Heaney


>>>>> "Matthew" == Matthew Heaney <mheaney@ni.net> writes:

Matthew> Is assignment of an access parameter to an object of a named
Matthew> (general) access type legal?  The code below compiles under
Matthew> my compiler (GNAT), but not on others (Rational, Aonix).  Who
Matthew> is correct?

With my wavefront version of GNAT, I get:

Compiling: test_p.adb (source file time stamp: 1997-03-26 11:11:05)

     7.       OTA : P.TA := OA;  -- ???
                            |
        >>> expected type "TA" defined at p.ads:6
        >>> found type access to "T" defined at line 6

You have to use explicit type conversion into a general access type
(P.TA in your case) to make it work (OTA : P.TA := P.TA (OA);)

  Sam
--
Samuel Tardieu -- sam@ada.eu.org




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

end of thread, other threads:[~1997-03-26  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-03-26  0:00 Is assignment available for access parameters? Matthew Heaney
1997-03-26  0:00 ` Samuel Tardieu

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