comp.lang.ada
 help / color / mirror / Atom feed
From: anon@anon.org (anon)
Subject: Re: Pointer types (I mean access types)
Date: Sat, 11 Jul 2009 19:41:08 GMT
Date: 2009-07-11T19:41:08+00:00	[thread overview]
Message-ID: <oV56m.436696$4m1.204112@bgtnsc05-news.ops.worldnet.att.net> (raw)
In-Reply-To: t9lf55t55qh7puub368vnr55pf215d9nmh@4ax.com

Most books on both languages have the link link example. just find one 
for each lang and compare. Execpt for the deallocation routine, your 
list look correct.

In Ada, for deallocation, there is a package "Ada.Unchecked_Deallocation" that 
is used to create a Free or Delete routinue for each type. An example taken 
from Ada.Text_IO is:

  -- Text_AFCB is a predefined record.

   procedure AFCB_Free (File : access Text_AFCB) is
      type FCB_Ptr is access all Text_AFCB;
      FT : FCB_Ptr := FCB_Ptr (File);

      procedure Free is new Ada.Unchecked_Deallocation (Text_AFCB, FCB_Ptr);

   begin
      Free (FT);
   end AFCB_Free;



In <t9lf55t55qh7puub368vnr55pf215d9nmh@4ax.com>, Rob Solomon <usenet@drrob1-noreply.com> writes:
>I am trying to understand how pointers work in Ada.  I would like to
>know if I have the correct equivalencies
>
>Assume this declaration:
>  type List_Node;  -- An incomplete type declaration.
>  type List_Node_Access is access List_Node;
>  type List_Node is
>    record
>      Data        : Integer;
>      Next        : List_Node_Access;
>    end record;
>
>Ada                                               Modula-2 (or Pascal)
>--------------------------------             ----------------------
>type Node_Access is access Node; TYPE NodeAccess = POINTER TO Node;
>Start : Node_Access;                      VAR Start : NodeAccess;
>Current := new Node;                    Current := NEW(Node);
>Current := Start;                            Current := Start;
>Current.all := Start.all;                   Current^ := Start^;
>Current.Data := 5;                         Current^.Data := 5;
>
>
>I never learned C or derivatives.  So comparisons to C don't help me.
>
>Thanks




  parent reply	other threads:[~2009-07-11 19:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-11  0:03 Pointer types (I mean access types) Rob Solomon
2009-07-11  0:59 ` Adam Beneschan
2009-07-11  1:23 ` Randy Brukardt
2009-07-11  9:01   ` Hibou57 (Yannick Duchêne)
2009-07-11 19:41 ` anon [this message]
2009-07-12  9:03 ` Gautier write-only
replies disabled

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