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=0.7 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,75f02dbbddbbdc88,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.75.170 with SMTP id d10mr3342191pbw.6.1323908050144; Wed, 14 Dec 2011 16:14:10 -0800 (PST) Path: lh20ni23281pbb.0!nntp.google.com!news2.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: "Rego, P." Newsgroups: comp.lang.ada Subject: Pop function Date: Wed, 14 Dec 2011 16:06:26 -0800 (PST) Organization: http://groups.google.com Message-ID: <27517259.83.1323907586856.JavaMail.geo-discussion-forums@yqgn9> Reply-To: comp.lang.ada@googlegroups.com NNTP-Posting-Host: 189.18.155.47 Mime-Version: 1.0 X-Trace: posting.google.com 1323908050 26747 127.0.0.1 (15 Dec 2011 00:14:10 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 15 Dec 2011 00:14:10 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=189.18.155.47; posting-account=TRgI1QoAAABSsYi-ox3Pi6N-JEKKU0cu User-Agent: G2/1.0 X-Google-Web-Client: true Content-Type: text/plain; charset=ISO-8859-1 Date: 2011-12-14T16:06:26-08:00 List-Id: 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?)