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!news.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Introductory Presentations, especially aimed at C++ programmers! Date: Wed, 14 Dec 2016 17:00:49 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <1905815374.502825168.454102.laguest-archeia.com@nntp.aioe.org> <877f7b5llo.fsf@nightsong.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 14 Dec 2016 23:59:32 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="c792994b68714a610d497daea35e6e89"; logging-data="18848"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/N2lcaAm1VCwSNeqb12VTgyAHRogZRi7c=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 In-Reply-To: Cancel-Lock: sha1:mZHq41dy3p3EeJoVIR0Y2rdumWA= Xref: news.eternal-september.org comp.lang.ada:32838 Date: 2016-12-14T17:00:49-07:00 List-Id: On 12/14/2016 03:48 PM, Randy Brukardt wrote: > "Jeffrey R. Carter" wrote in message > news:o2q2o6$c16$1@dont-email.me... >> >> The difference is that, for every recursive call, the GNAT version >> declares 2 buffers, and mine only declares 1. > > ...and generates a second one implicitly. Still no difference. The semantics > of & require a copy, it can't be optimized out (with the possible exception > of a direct assignment to something). Maybe. I'm not a compiler writer, and I understand that GNAT's version may have been written with a deep understanding of what the GNAT compiler will do with the code. But from a general point of view, I take the view that the compiler can do a better job of optimization than I can, so letting it do an implicit 2nd declaration is the way to go. Also return Line & Get_Line; is tail recursion; IIUC, Erlang compilers are required to optimize tail recursion away, so such an optimization must be reasonably easy to implement. Maybe an Ada compiler does it, too. Again, I'd rather give the compiler the ability to do that optimization. >> ... Worrying about the efficiency of very rare situations, given the >> general >> inefficiency of Text_IO anyway, seems like a waste of time. > > Customers would disagree with you. I once had to refund a customer because > they complained about the efficiency of our Text_IO vs. that of the similar > C functions. I spent several weeks redoing Text_IO in part because of that > experience (mostly so the performance of Get_Line from files is better). > > It's very usual that a new customer will write a trial program with their > shiny new compiler that just reads some text file with Get_Line. Us old Ada > hands know better than to expect great performance from that, but one does > not want someone's first impression of Ada to be bad. Thus the performance > of Get_Line is one of those things that has to be optimized absolutely as > much as possible. (One cannot get into arguments of premature optimization > if they are returning their compiler and switching to some other > language!!!) I suspect your customer was looking for an excuse not to use Ada. There's no way Text_IO can be as efficient as C equivalents. I'm not aware of a C equivalent of the Get_Line function. Anyway, since Janus/Ada is an Ada-95 compiler, you're talking about a different Get_Line. -- Jeff Carter "I was in love with a beautiful blonde once, dear. She drove me to drink. That's the one thing I'm indebted to her for." Never Give a Sucker an Even Break 109