READ-FILE READ-LINE REPOSITION-FILE contain clauses stating an ambiguous condition exists if file is positioned outside the file boundaries.
AFAIK common practice in the real world is to allow file-positioning anywhere
and let the subsequent read/write handle it - which in most cases won't return
an error. Reading beyond end-of-file should return 0 bytes read and ior=0; writing beyond end-of-file is the basis of 'sparse' random access files.
READ-FILE READ-LINE REPOSITION-FILE contain clauses stating an ambiguous >condition exists if file is positioned outside the file boundaries.
AFAIK common practice in the real world is to allow file-positioning anywhere >and let the subsequent read/write handle it
I guess the ambiguity is because a 'file' can be any device, e.g., a keyboa= >rd, printer,
or a tape drive, or a paper tape ...
dxforth <dxforth@gmail.com> writes:
READ-FILE READ-LINE REPOSITION-FILE contain clauses stating an ambiguous
condition exists if file is positioned outside the file boundaries.
AFAIK common practice in the real world is to allow file-positioning anywhere
and let the subsequent read/write handle it
What makes you think so? The first system I checked (Gforth on Linux) behaves differently:
#200000. stdout reposition-file throw
*the terminal*:7:33: error: Illegal seek
#200000. stdout reposition-file >>>throw<<<
For a seekable file it seems that it indeed behaves as you describe:
[~/gforth:139436] echo >/tmp/xxx
[~/gforth:139437] gforth
...
s" /tmp/xxx" r/o open-file throw ok 1
constant xxx ok
#20000. xxx reposition-file throw ok
here 10 xxx read-file throw . 0 ok
In any case, given that all three words produce iors, an ambiguous
condition is not merited IMO. REPOSITION-FILE should either return a non-zero ior, or a zero ior. Similarly, for READ-FILE and READ-LINE,
if the position is outside the written part of the file, they should
behave as you describe, or maybe return a non-zero ior (not sure if
there are any (operating or Forth) systems that need that). But who
is going to write the proposal?
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 300 |
Nodes: | 16 (2 / 14) |
Uptime: | 36:44:05 |
Calls: | 6,707 |
Files: | 12,239 |
Messages: | 5,353,438 |