From: Adam Beneschan <adam@irvine.com>
Subject: Re: Pop function
Date: Wed, 14 Dec 2011 18:08:52 -0800 (PST)
Date: 2011-12-14T18:08:52-08:00 [thread overview]
Message-ID: <b09f0a32-80e5-460d-86a9-881e19c45d77@h11g2000yqd.googlegroups.com> (raw)
In-Reply-To: 778917968345601399.621922martin-re.mo.ve.thedowies.com@news.btinternet.com
On Dec 14, 4:29 pm, Martin Dowie <mar...@re.mo.ve.thedowies.com>
wrote:
> "Rego, P." <pvr...@gmail.com> wrote:
> > 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?)
>
> If Sender is null, your in trouble before you get to "begin".
First it's "here" instead of "hear", now it's "your" instead of
"you're"..........
:)
-- Adam
next prev parent reply other threads:[~2011-12-15 2:22 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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.
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox