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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: storage error: stack overflow Date: Wed, 19 Aug 2015 14:47:41 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <87k2srf1j8.fsf@theworld.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Wed, 19 Aug 2015 21:46:00 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="ee44d3db9c41f5ad88d7e8e8f0268f05"; logging-data="10015"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/EYwQJKHCTrxCzAquQ+WOpvIomuGDjaew=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 In-Reply-To: <87k2srf1j8.fsf@theworld.com> Cancel-Lock: sha1:1YAcC9S8JBHxnYHNP328DX4L/Qo= X-Enigmail-Draft-Status: N1110 Xref: news.eternal-september.org comp.lang.ada:27514 Date: 2015-08-19T14:47:41-07:00 List-Id: On 08/19/2015 01:47 PM, Bob Duff wrote: > "Jeffrey R. Carter" writes: >> >> You do not /need/ access types for this. Avoiding them requires some thought, >> but that's what S/W engineers do. > > I don't think it's fair to say that people who use access types > (i.e. pointers) aren't proper "S/W engineers". It's true that Ada > doesn't require pointers in many cases where other languages do. > But Ada still requires pointers if the class-wide variable > needs to change its tag. And pointers are required for recursive > data structures. Etc. I didn't say that people who use access types aren't proper S/W engineers. I implied that people who use access types unnecessarily because they're unwilling or unable to do the extra thinking needed to avoid aren't S/W engineers. > I think what you and Randy have been saying (or should have been?) > is more like: > > 1. Try to avoid using pointers. > > 2. When you have to use them, try to encapsulate. > > 3. When possible, use the encapsulations already provided by the > language (i.e. the Ada.Containers). > > But there are all sorts of reasons why Ada.Containers might not be > suitable, so in those cases, you WILL use pointers, preferably > encapsulated. But that's different from saying "never use pointers" > (or "never use access types"). Almost. Using an abstraction that happens to be implemented using pointers is not the same as using pointers. The whole point of the abstraction is so the user doesn't have to think in the terms of its implementation. For example, when I write Ada, the compiler implements it in machine code. Ada is an abstraction that allows me to not have to think in terms of machine code. I consider it incorrect to refer to using Ada as using machine code. I also think it's incorrect to refer to using an abstraction implemented with pointers as using pointers. So I'd probably say: Before using pointers, 1. Try to use an existing abstraction that doesn't require using pointers, such as Ada.Containers. 2. If that's not possible, try to create an abstraction that encapsulates the use of pointers and doesn't require its user to use pointers. 3. If that's not possible, then see if there's anything else that will allow you to avoid using pointers. 4. If that's not possible, then use pointers. -- Jeff Carter "Alms for an ex-leper!" Monty Python's Life of Brian 75