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.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA 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.213.71 with SMTP id nq7mr3642972pbc.2.1323918038845; Wed, 14 Dec 2011 19:00:38 -0800 (PST) Path: lh20ni23721pbb.0!nntp.google.com!news1.google.com!news.glorb.com!news.netfront.net!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: Pop function Date: Wed, 14 Dec 2011 20:00:34 -0700 Organization: Also freenews.netfront.net; news.tornevall.net Message-ID: References: <27517259.83.1323907586856.JavaMail.geo-discussion-forums@yqgn9> <30092575.120.1323912907099.JavaMail.geo-discussion-forums@yqja5> NNTP-Posting-Host: 97.224.152.136 Mime-Version: 1.0 X-Trace: adenine.netfront.net 1323918035 38148 97.224.152.136 (15 Dec 2011 03:00:35 GMT) X-Complaints-To: news@netfront.net NNTP-Posting-Date: Thu, 15 Dec 2011 03:00:35 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.23) Gecko/20110922 Thunderbird/3.1.15 In-Reply-To: <30092575.120.1323912907099.JavaMail.geo-discussion-forums@yqja5> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Date: 2011-12-14T20:00:34-07:00 List-Id: On 12/14/2011 06:35 PM, Rego, P. wrote: >> Your public interface should never use access types. Anonymous types are a >> bad idea. > Why so does the language allow it? Currently I could not think a better way > of running over a pointer list: get the item, run the top of the list to the > next one (and also keep the original pointer), free the original pointer and > return the (newest) pointer to the top of the list. The problem I got was > exactly when I tried to do this directly from the input access (so the > anonymous type problem) The language allows lots of things that are bad ideas: anonymous types, programming by extension, the list goes on. That's not a reason to use them. While an unbounded list undoubtedly is implemented using access values, there is no reason to expose them to your clients. The best way to run over a list is to reuse an existing implementation, such as Ada.Containers.Doubly_Linked_List, or PragmARC.List_Unbounded_Unprotected if you don't have access to a compiler for the current language. One wonders why you are trying to write another one. >> Psychologists have found that the 1st few letters of a word are the most >> important to recognizing what you're seeing. If many of your identifiers >> start with the same few letters ("T_"), you are making your code harder to >> read than necessary. > I agree, but that's ok here. Think this as "be a general list type named > T_List ..." It's never OK to make your code harder to read. -- Jeff Carter "English bed-wetting types." Monty Python & the Holy Grail 15 --- Posted via news://freenews.netfront.net/ - Complaints to news@netfront.net ---