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,8de7eedad50552f1 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Ada bench : count words Date: 22 Mar 2005 08:58:37 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <87vf7n5njs.fsf@code-hal.de> <423f5813$0$9224$9b4e6d93@newsread4.arcor-online.net> <18arnvu705ly4$.1wz6ybz1jt70y$.dlg@40tude.net> <1q9cx4jt7802s.k45m6mcntl87$.dlg@40tude.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1111499917 1181 192.74.137.71 (22 Mar 2005 13:58:37 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Tue, 22 Mar 2005 13:58:37 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:9733 Date: 2005-03-22T08:58:37-05:00 List-Id: "Dmitry A. Kazakov" writes: > On Tue, 22 Mar 2005 11:57:22 +0000, Marius Amado Alves wrote: > > >>> ... To implement buffering, I have resorted to > >>> Ada.Direct_IO, which I think cannot apply to standard input. > >> > >> Is Text_IO that bad? > > > > No, if you can solve The Get_Line puzzle :-) > > What about Get (Item : out Character)? > > I wonder if calling C-lib's read would qualify! (:-)) Text_IO is pretty broken, from both a usability perspective and an efficiency perspective. I normally avoid it, and use pragma Import on the C routines (open, read, etc). Suitably wrapped in a clean interface, of course. I recently installed some third-party code into my project, which was using Direct_IO (not Text_IO). I rewrote it to use my I/O routines, and that part of the program sped up by a couple orders of magnitude. > I think Text_IO should translate it into LF. But anyway you can always > assume LF = new line, CR = space in the FSM. It's astonishing how much human intellectual work has been wasted on stupid issues like CR/LF vs. LF! And endianness. > FSM is one of that rare cases where gotos are natural. What a pity that Ada > does not have arrays of labels! (:-)) I prefer a loop containing a case statement. This has the advantage that you can insert extra code that happens on every state transition (e.g. assert that you didn't forget to set the next state explicitly, print out the state transitions for debugging, etc). But in *this* case, I'd just use a bunch of while loops and case statements and so forth. In my experience, most state machines have plenty of structure, so the totally unstructured methods: (loop-with-case or rats-nest-of-gotos or state-transition-table) seem unnecessary. - Bob