comp.lang.ada
 help / color / mirror / Atom feed
* Pop function
@ 2011-12-15  0:06 Rego, P.
  2011-12-15  0:29 ` Martin Dowie
                   ` (2 more replies)
  0 siblings, 3 replies; 27+ messages in thread
From: Rego, P. @ 2011-12-15  0:06 UTC (permalink / raw)


Hello, 

Given a list type 
   type T_List is
      record
         Next : access T_List;
         Item : Integer;
      end record;
   T_List_Ptr is access T_List;

Is it right to implement a pop function like the following? (Free is an Unchecked_Deallocation)
   function Pop (Sender : access T_List) return Integer is
      Current_Sender_Ptr : T_List_Ptr := T_List_Ptr (Sender);
      Current_Item : constant T_List := Sender.Item;
   begin
      if Sender /= null then
         if Sender.Next /= null then
            Current_Sender_Ptr := T_List_Ptr (Current_Sender_Ptr.Next);
         end if;
		 Free (Current_Sender_Ptr);
         return Current_Item;
      else 
         return 0;
      end if;
   end Pop;

I mean, if I set Current_Sender_Ptr := T_List_Ptr (Current_Sender_Ptr.Next), it's equivalent to Sender := Sender.Next? (which I could not do directly due to in this case it would not be allowed an anonymous reference, right?)



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

end of thread, other threads:[~2011-12-28 13:04 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-15  0:06 Pop function Rego, P.
2011-12-15  0:29 ` Martin Dowie
2011-12-15  1:23   ` Rego, P.
2011-12-15  2:08   ` Adam Beneschan
2011-12-15 22:59     ` Martin Dowie
2011-12-16 10:27       ` georg bauhaus
2011-12-15  0:34 ` Jeffrey Carter
2011-12-15  1:35   ` Rego, P.
2011-12-15  2:55     ` Alex Mentis
2011-12-15  3:00       ` Alex Mentis
2011-12-15  3:00     ` Jeffrey Carter
2011-12-15  3:41       ` Rego, P.
2011-12-15  8:38   ` Dmitry A. Kazakov
2011-12-15 19:57     ` Jeffrey Carter
2011-12-15 20:15       ` Dmitry A. Kazakov
2011-12-15 21:02         ` Simon Wright
2011-12-15 21:25           ` Jeffrey Carter
2011-12-16  8:23           ` Dmitry A. Kazakov
2011-12-16  0:31       ` Randy Brukardt
2011-12-15  2:06 ` Adam Beneschan
2011-12-15  3:27   ` Rego, P.
2011-12-15 12:43     ` Simon Wright
2011-12-15 15:54       ` Adam Beneschan
2011-12-15 18:34         ` Simon Wright
2011-12-15 19:14           ` Dmitry A. Kazakov
2011-12-15 16:14     ` Adam Beneschan
2011-12-28 13:04       ` Rego, P.

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