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,UTF8 Received: by 10.68.74.201 with SMTP id w9mr2957165pbv.0.1323974101080; Thu, 15 Dec 2011 10:35:01 -0800 (PST) Path: lh20ni26182pbb.0!nntp.google.com!news2.google.com!goblin2!goblin.stu.neva.ru!newsfeed1.swip.net!85.214.198.2.MISMATCH!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Pop function Date: Thu, 15 Dec 2011 18:34:53 +0000 Organization: A noiseless patient Spider 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> Mime-Version: 1.0 Injection-Info: mx04.eternal-september.org; posting-host="dFCm8HWntFqmDIilBLqEJQ"; logging-data="7209"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18XRVkNNR9jMPHkHOcPo/Fa66vwmwXnV8k=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (darwin) Cancel-Lock: sha1:yYTZqK4ZdMMp0S50pdd2oc4Rtmw= sha1:l5EVgJgn6CRDIFZwYBqGPBKrrfU= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Date: 2011-12-15T18:34:53+00:00 List-Id: Adam Beneschan writes: > On Dec 15, 4:43 am, Simon Wright wrote: >> I don't see why Pop takes T_List_Ptr as an argument. I would have >> written >> >>     procedure Pop (Sender : in out T_List; >>                    T_Item : out Integer) is >> >> and then it would be primitive (assuming T_List is tagged). > You could quibble about whether T_List is an appropriate name to > represent a list element. Fine. I would too. But I think our first > objective should get our OP to help write code that works, which > involves making sure he (I assume) understands the Ada language issues > involved, and not adding to any confusion he might have. We can > quibble about the names, readability issues, encapsulation issues, > etc., later. I see what you mean; you've realised that OP is probably confused, whereas I just got confused myself. I agree about writing code that works, but that does sometimes involve working out how best to state the problem. I don't think that it's quibbling to point to unclear thinking; if the design is wrong that's not an Ada language issue, and using inappropriate names is a red flag for design problems. 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. I have in the past implemented lists where the 'head' element was just another member which -- by convention -- wasn't part of the list. That sort of thing needs to be done by consenting adults in private, though.