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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a4d2751f9487bd38 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-06 21:27:56 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news-out1.nntp.be!propagator2-sterling!news-in-sterling.nuthinbutnews.com!cyclone1.gnilink.net!spamkiller2.gnilink.net!nwrdny02.gnilink.net.POSTED!53ab2750!not-for-mail From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5a) Gecko/20030611 Thunderbird/0.1a X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Real data for a change in the assignment operators and Bounded_String discussions. References: <3F04F778.5090305@attbi.com> In-Reply-To: <3F04F778.5090305@attbi.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Mon, 07 Jul 2003 04:27:55 GMT NNTP-Posting-Host: 162.83.152.221 X-Complaints-To: abuse@verizon.net X-Trace: nwrdny02.gnilink.net 1057552075 162.83.152.221 (Mon, 07 Jul 2003 00:27:55 EDT) NNTP-Posting-Date: Mon, 07 Jul 2003 00:27:55 EDT Xref: archiver1.google.com comp.lang.ada:40094 Date: 2003-07-07T04:27:55+00:00 List-Id: Robert I. Eachus wrote: > Open(Input_File,In_File,Argument(1)); > return Recur; > Close(Input_File); What's this? Does Ada come with a delay slot? > You just CANNOT code like this in C or many other languages. True. > (I can imagine trying to write that code in C, with mallocs, frees, > searches for nul (strlen) and copies all over the place. Ouch!) Well, let's see (error checking left out): char *first_line_of_file(char *file_name) { int nread = 0, capacity = 0, c; char *buf = 0; FILE *f = fopen(file_name, "r"); while ((c = fgetc(f)) != EOF && c != '\n') { if (nread >= capacity) buf = realloc(buf, capacity += 80); buf[nread++] = c; } fclose(f); if (nread >= capacity) buf = realloc(buf, capacity + 1); buf[nread] = 0; return realloc(buf, nread + 1); } I suggest your imagination was unequal to the task. And in C++, the whole thing is a single call to std::getline. > I don't expect this to end the discussion on these two issues, but I > hope it helps. The three calls in a row to Inc are much clearer than: But you have cheated, by having all three lines increment an Integer. Ada not being C, there are a proliferation of user-defined types that all need incrementing, so soon the code is crawling with simple little Inc and Dec procedures. The idea behind having special assignment operators (or idem) is precisely to avod having to write these little procedures for every such type.