From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,75f02dbbddbbdc88 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Received: by 10.68.73.229 with SMTP id o5mr3567034pbv.7.1323915762774; Wed, 14 Dec 2011 18:22:42 -0800 (PST) Path: lh20ni23621pbb.0!nntp.google.com!news2.google.com!postnews.google.com!h11g2000yqd.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Pop function Date: Wed, 14 Dec 2011 18:08:52 -0800 (PST) Organization: http://groups.google.com Message-ID: References: <27517259.83.1323907586856.JavaMail.geo-discussion-forums@yqgn9> <778917968345601399.621922martin-re.mo.ve.thedowies.com@news.btinternet.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 X-Trace: posting.google.com 1323915762 7311 127.0.0.1 (15 Dec 2011 02:22:42 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 15 Dec 2011 02:22:42 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: h11g2000yqd.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: ARLUEHNKC X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C),gzip(gfe) Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2011-12-14T18:08:52-08:00 List-Id: On Dec 14, 4:29=A0pm, Martin Dowie wrote: > "Rego, P." wrote: > > Hello, > > > Given a list type > > =A0 =A0type T_List is > > =A0 =A0 =A0 record > > =A0 =A0 =A0 =A0 =A0Next : access T_List; > > =A0 =A0 =A0 =A0 =A0Item : Integer; > > =A0 =A0 =A0 end record; > > =A0 =A0T_List_Ptr is access T_List; > > > Is it right to implement a pop function like the following? (Free is an > > Unchecked_Deallocation) > > =A0 =A0function Pop (Sender : access T_List) return Integer is > > =A0 =A0 =A0 Current_Sender_Ptr : T_List_Ptr :=3D T_List_Ptr (Sender); > > =A0 =A0 =A0 Current_Item : constant T_List :=3D Sender.Item; > > =A0 =A0begin > > =A0 =A0 =A0 if Sender /=3D null then > > =A0 =A0 =A0 =A0 =A0if Sender.Next /=3D null then > > =A0 =A0 =A0 =A0 =A0 =A0 Current_Sender_Ptr :=3D T_List_Ptr (Current_Sen= der_Ptr.Next); > > =A0 =A0 =A0 =A0 =A0end if; > > =A0 =A0 =A0 =A0 =A0 =A0 Free (Current_Sender_Ptr); > > =A0 =A0 =A0 =A0 =A0return Current_Item; > > =A0 =A0 =A0 else > > =A0 =A0 =A0 =A0 =A0return 0; > > =A0 =A0 =A0 end if; > > =A0 =A0end Pop; > > > I mean, if I set Current_Sender_Ptr :=3D T_List_Ptr > > (Current_Sender_Ptr.Next), it's equivalent to Sender :=3D 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