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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9c86eb13dd395066 X-Google-Attributes: gid103376,public From: kilgallen@eisner.decus.org (Larry Kilgallen) Subject: Re: CRC in Ada? Date: 1997/03/06 Message-ID: <1997Mar6.091150.1@eisner>#1/1 X-Deja-AN: 223538204 X-Nntp-Posting-Host: eisner.decus.org References: <1997Mar2.220652@nova.wright.edu> X-Nntp-Posting-User: KILGALLEN X-Trace: 857657520/27364 Organization: LJK Software Newsgroups: comp.lang.ada Date: 1997-03-06T00:00:00+00:00 List-Id: In article , ohk@edeber.tfdt-o.nta.no (Ole-Hjalmar Kristensen FOU.TD/DELAB) writes: > In article <1997Mar5.131846.1@eisner> kilgallen@eisner.decus.org (Larry Kilgallen) writes: > performance. Those reading sequentially from disk should > likewise concern themselves with performance, and 512 calls > to even the lightest-weight library is too much if a single > call would do. For the stated problem (CRC) reading large > blocks is a clear win. > > I think you are missing something here. Altough in Unix it IS possible > to do reads of arbitrary length, the standard IO library of C > definitely does IO in blocks. The getc/putc functions are > usually implemented as macros, which just manipulate the buffer. Of And relying on performance characteristics of a particular implementation which are not mandated from implementation to implementation brings problems. (Perhaps this implementation technique _is_ mandated, but it is not something I would know.) > > I'm not sure why reading a file character-by-character is "C-like". > > It seems like the natural way to write lots of programs, in any > > language. The underlying language and OS should ensure that it can be > > done efficiently (by making the "give-me-a-char" routine read from a > > buffer whenever appropriate). > > In my experience it is generally C programmers who make this mistake. > Perhaps it because many of them come from a Unix background where there > is no strong sense of a "record". On the other hand, it may just be > that there are so many C programmers that statistically speaking most > of the mistakes made will be made by a C programmer. > It should be no harder to implement the putc/getc funtions on any > other OS which allows you to do character IO in blocks, than it is in Unix. And any vendor in the non-Unix space can choose to emulate as many Unix characteristics as they choose, including performance-related ones or not. > It may be a mistake in some cases, but talking about "this mistake" is > a vast oversimplification. Surely, there is nothing conceptually wrong > with having a set of single character IO operations like putc, getc, > and ungetc? It is a mistake to assume performance semantics (if that is the term) which are not present in the target environment. Don't get me wrong, I think there are many instances for non-portable code in the world. However just because something written in Ada (or C) will compile and get the right answer in another environment, that does not mean it is portable from the standpoint of the end user who must wait for the results. Larry Kilgallen