Re: The concept of a record
- From: nospam@xxxxxxxxxxxxx (Richard Maine)
- Date: Thu, 31 Jan 2008 08:23:34 -0800
LC's No-Spam Newsreading account <nospam@xxxxxxxxxxxxxx> wrote:
SEQUENTIAL FORMATTED...
DIRECT UNFORMATTED...
DIRECT FORMATTED is possible if you want to output readable text
files, but be able to access records at random. But one could also
read unformatted into a string, and use internal i/o
Direct access formatted is *NOT* typically a readable text file. It is
likely to not have line terminators. Adding them manually is posssible,
but non-portable. Implementations can vary on this.
I personally have (almost?) never used direct access formatted, but I've
heard from people who do.
SEQUENTIAL UNFORMATTED according to me should be avoided, because
the way the variable record length is coded may be OS and language
dependent, and therefore not portable or interoperable ... it means
looking for troubles ! I believe I used it only in very few special
cases when writing over named pipes.
Sequential unformatted is extremely widespread and has lots of good
reasons for use. It was one of the only 2 options available until f77
(as there was formerly no direct access). You are right that it can have
portability issues. But that is not always critical. And there are times
when it is important, but not so much so as to completely overwhelm all
other considerations. The fixed record lengths of direct access can
sometimes be a significant barrier. Formatted I/O has a huge performance
penalty, in addition to the potential problems of loss of precision.
Note also that the portability of direct access unformatted is also not
guaranteed. In fact the standard says nothing that requires portability
of such files any more than it does of sequential formatted. The most
common implementation choice of direct access unformatted happens to be
more portable than the most common implementation choices of sequential
unformatted, but this is not specified by the standfard. There are
implementations that don't use the most common choice for direct
acccess. Plus, of course, you won't have portability in any case across
machines with different data representations.
For f2003, the portability and interoperability of unformatted stream is
probably the best you will be able to get for unformatted. That is the
only case of unformatted I/O where the standard actually does address
the issue.
--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.
- References:
- The concept of a record
- From: qsc
- Re: The concept of a record
- From: LC's No-Spam Newsreading account
- The concept of a record
- Prev by Date: Re: computing Bernoulli numbers
- Next by Date: Re: Fortran 2003: abstract interfaces
- Previous by thread: Re: The concept of a record
- Next by thread: OT Launched - pictures from Andoya, Norway - Andenes, Bleik, and the rocket range
- Index(es):
Relevant Pages
|
|