Clarity on line (and page) endings for Algol 68 transput
chris hermansen
clhermansen@gmail.com
Tue Jul 7 19:28:11 GMT 2026
Good afternoon everyone,
I am trying to find clarity on "the proper way" of handling of line (and
page) endings in Algol 68 transput.
Back in the day, I wrote several articles on Algol 68 for
https://www.opensource.com. In one, I talked about using closures with
"here procedures" to facilitate processing data from delimited text files.
Doing that, I found that when I wanted to read a line of text I needed to
include "newline" in order to skip over line-ending characters; for example:
file inf;
open(inf, input_file_name, stand_in_channel);
bool finished_reading := false;
on logical file end (inf, (ref file f) bool: finished_reading := true);
while
string line;
get(inf,(line, newline));
not_finished_reading
do
...
od
(this was using Algol 68 Genie at that time).
However, in McGettrick p.38, I read (for example):
--
The effect of a read statement such as
read((a, b, c, d)
is, at least for present purposes, the same as the four read statements
read(a); read(b); read(c); read(d)
It is convenient therefore to consider only read statements of the form
"read(a)" where "a" is a single variable or, more precisely, a single
object. The effect of more complex read statements can then be defined in
terms of the simpler statements.
The effect of "read(x)" will now be considered. There are several cases to
be discussed. These arise from the different possible modes of "x".
(i) Suppose "x" has mode "ref int". The input is devoured until the first
non-blank character is encountered. Newlines are taken if necessary. The
integer is then read and assigned to the variable "x". It will be
terminated by a non-digit character or by a new line, whichever comes
first...
...
(iv) Suppose "x" has mode ref char. If the reading position is at the end
of the line, a new line is taken. The first character is read and assigned
to "x".
--
This "Newlines are taken if necessary" approach does not seem to match my
experience with reading a text file line by line into ref string
variables. Explicitly, as I mentioned above, to move to the next line in
order to read it, I had to issue a newline.
Does anyone have any advice on this matter?
Thanks in advance!
--
Chris Hermansen · clhermansen "at" gmail "dot" com
C'est ma façon de parler.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://gcc.gnu.org/pipermail/algol68/attachments/20260707/1e604b2f/attachment.htm>
More information about the Algol68
mailing list