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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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-7-bit Received: by 10.68.189.233 with SMTP id gl9mr5820923pbc.8.1323976489577; Thu, 15 Dec 2011 11:14:49 -0800 (PST) Path: lh20ni26292pbb.0!nntp.google.com!news2.google.com!news1.google.com!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Pop function Date: Thu, 15 Dec 2011 20:14:41 +0100 Organization: cbb software GmbH Message-ID: References: <27517259.83.1323907586856.JavaMail.geo-discussion-forums@yqgn9> <31100824.174.1323919653265.JavaMail.geo-discussion-forums@yqcs5> <0357a0a8-9e3e-4011-bb40-0d82700d70b2@o7g2000yqk.googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: BChg1jyHRzVQHsaTbkEJkw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2011-12-15T20:14:41+01:00 List-Id: On Thu, 15 Dec 2011 18:34:53 +0000, Simon Wright wrote: > Here, for example, if I write > > L : aliased T_List; > ... > begin > ... > J := Pop (L'Access); > > I'm going to get a crash at runtime because I'm trying to deallcate > memory that was never allocated. Another reason to have it an explicit access type, BTW. If L were access to specific pool you would not be able to declare L on the stack. > I have in the past implemented lists where the 'head' element was just > another member which -- by convention -- wasn't part of the list. I tried: type Item is access Element_Type; type List is new Item; and then to separate elements and lists in operations. E.g. procedure Delete (Container : in out List; Element : in out Item); Item becomes null, Container set to the new head. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de