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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,b5cd7bf26d091c6f X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!hv8g2000vbb.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: Reading the while standard input into a String Date: Mon, 6 Jun 2011 11:36:00 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <1e5e764d-eb7b-4804-8119-b535ddbe5e7e@32g2000vbe.googlegroups.com> <1a84tm53l1wjx.1xdgsbp25vyd5.dlg@40tude.net> NNTP-Posting-Host: 83.3.40.82 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1307385360 1591 127.0.0.1 (6 Jun 2011 18:36:00 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 6 Jun 2011 18:36:00 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: hv8g2000vbb.googlegroups.com; posting-host=83.3.40.82; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESNKRC X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:19648 Date: 2011-06-06T11:36:00-07:00 List-Id: On Jun 6, 8:18=A0pm, "Dmitry A. Kazakov" wrote: > > This is a can of warms - how big should be that chunk? :-) > > For a compiler it is the maximal length of look ahead / roll-back, > normally, less than just one line. This is wrong even for Ada. The compiler cannot drop what it read so far (except maybe for comments) - it has to retain this information, even if not literally in its original form. This means that "dropping" data is not possible and in fact the internal data structures will grow while the file is being processed - but then the compiler might as well just read the whole source file into memory and I bet this will be much smaller that the data structures that are built from it. BTW - what about generating debug version of the executable with source embedded? Oops. You'd better keep it around, it's cheap when compared to anything else. > > Or not. System calls are relatively expensive - typically much more > > expensive than copying data around. For this reason wisely used > > additional buffers can improve performance of I/O operations. > > The opposite is also possible, unless the OS driver uses user-space > buffers. So I would follow Ludovic's advise, especially in the case of a > compiler where reading overhead is negligible comparing to other > computations per character. There is no point in following this advice, because compiler is not cat or grep. In particular, the compiler does not work on potentially infinite streams (unlike cat and grep) and there is a clear concept of a program structure that has its end. This means that reading the whole source file into memory is a perfectly valid approach. -- Maciej Sobczak * http://www.msobczak.com * http://www.inspirel.com