comp.lang.ada
 help / color / mirror / Atom feed
* Re: Assignment of Classwide Types
  1998-09-03  0:00 Assignment of Classwide Types jsanchor
  1998-09-03  0:00 ` Martin C. Carlisle
@ 1998-09-03  0:00 ` dennison
  1998-09-04  0:00 ` Tom Moran
  2 siblings, 0 replies; 4+ messages in thread
From: dennison @ 1998-09-03  0:00 UTC (permalink / raw)


In article <6smnns$2vj$1@nnrp1.dejanews.com>,
  jsanchor@cs5.dasd.honeywell.com wrote:

> type PARENT_TYPE is abstract tagged private;
>
> private
>     type PARENT_TYPE is abstract tagged with

> the compiler does not give any errors, but the assignment does not work.
> I looked at the assembly code and it seems that the compiler makes a call to
> deep_finalize, deep_adjust but to no effect.

You didn't say what compiler or platorm this is on. If that *exact* code with
a trivial test program is giving that behavior, I'd suggest emailing it to
your compiler vendor.

From your comments though, I'm suspicious that you don't really have

   type PARENT_TYPE is new Ada.Finalization.Controlled with....

but then again, it could be that your compiler *always* does an adjust and
finalize, even if the object isn't controlled. Without knowing your compiler
vendor/platform, who's to say?

--
T.E.D.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum




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

* Re: Assignment of Classwide Types
  1998-09-03  0:00 Assignment of Classwide Types jsanchor
@ 1998-09-03  0:00 ` Martin C. Carlisle
  1998-09-03  0:00 ` dennison
  1998-09-04  0:00 ` Tom Moran
  2 siblings, 0 replies; 4+ messages in thread
From: Martin C. Carlisle @ 1998-09-03  0:00 UTC (permalink / raw)


The following works for me.  Perhaps you could be more specific?

--Martin

with ada.integer_text_io;
procedure bob is
  type parent is abstract tagged record
     checksum : Integer;
  end record;
  
  type parent_access is access all parent'class;
  type child is new parent with record
     new_field : integer;
  end record;
  x, y : parent_access := new child;
begin
  y.checksum := 3;
  x.checksum := 4;
  x.all := y.all;
  Ada.Integer_Text_io.Put(x.checksum);
end bob;
In article <6smnns$2vj$1@nnrp1.dejanews.com>,
 <jsanchor@cs5.dasd.honeywell.com> wrote:
>Hello Everyone: I have a tagged type declared as
>
>type PARENT_TYPE is abstract tagged private;
>
>private
>    type PARENT_TYPE is abstract tagged with
>    record
>       checksum : INTEGER;
>    end record;
>
>    type ACCESS_TO_PARENT_TYPE is access all PARENT_TYPE'class;
>---------------------------------------------------------------
>
>  PTR1 : ACCESS_TO_PARENT_TYPE;
>  PTR2 : ACCESS_TO_PARENT_TYPE;
>
> I have PTR1 & PTR2 having access to diff. memory locations where I have
>PARENT_TYPE (same tag but diff. data).
>   then I say, PTR1.all := PTR2.all;
>
>the compiler does not give any errors, but the assignment does not work.
>I looked at the assembly code and it seems that the compiler makes a call to
>deep_finalize, deep_adjust but to no effect.
>
>Can someone explain how to get around this problem?
>Thank you in advance.
>Sincerely,
>Jay S.
>
>
>
>
>-----== Posted via Deja News, The Leader in Internet Discussion ==-----
>http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


-- 
Martin C. Carlisle, Computer Science, US Air Force Academy
mcc@cs.usafa.af.mil, http://www.usafa.af.mil/dfcs/bios/carlisle.html
DISCLAIMER:  This content in no way reflects the opinions, standard or 
policy of the US Air Force Academy or the United States Government.




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

* Assignment of Classwide Types
@ 1998-09-03  0:00 jsanchor
  1998-09-03  0:00 ` Martin C. Carlisle
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: jsanchor @ 1998-09-03  0:00 UTC (permalink / raw)


Hello Everyone: I have a tagged type declared as

type PARENT_TYPE is abstract tagged private;

private
    type PARENT_TYPE is abstract tagged with
    record
       checksum : INTEGER;
    end record;

    type ACCESS_TO_PARENT_TYPE is access all PARENT_TYPE'class;
---------------------------------------------------------------

  PTR1 : ACCESS_TO_PARENT_TYPE;
  PTR2 : ACCESS_TO_PARENT_TYPE;

 I have PTR1 & PTR2 having access to diff. memory locations where I have
PARENT_TYPE (same tag but diff. data).
   then I say, PTR1.all := PTR2.all;

the compiler does not give any errors, but the assignment does not work.
I looked at the assembly code and it seems that the compiler makes a call to
deep_finalize, deep_adjust but to no effect.

Can someone explain how to get around this problem?
Thank you in advance.
Sincerely,
Jay S.




-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum




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

* Re: Assignment of Classwide Types
  1998-09-03  0:00 Assignment of Classwide Types jsanchor
  1998-09-03  0:00 ` Martin C. Carlisle
  1998-09-03  0:00 ` dennison
@ 1998-09-04  0:00 ` Tom Moran
  2 siblings, 0 replies; 4+ messages in thread
From: Tom Moran @ 1998-09-04  0:00 UTC (permalink / raw)


If Parent_Type is really abstract as you say, then clearly PTR2 cannot
possibly be a pointer to something of Parent_Type, so PTR2.all cannot
exist.  But you also say there's something about finalize and
adjust...
  Are you sure your message didn't leave something out?




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

end of thread, other threads:[~1998-09-04  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-09-03  0:00 Assignment of Classwide Types jsanchor
1998-09-03  0:00 ` Martin C. Carlisle
1998-09-03  0:00 ` dennison
1998-09-04  0:00 ` Tom Moran

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