I have to admit first, that I did not read all the comments in this
thread. But anyway,
I'd like to comment on this. Because I have done Pascal programming for
almost 40 years
now and even on platforms that are much older than PCs and machines
typically run
by Unix systems, I have a somehow different view.
First of all, there is a good reason why Pascal has a WRITELN procedure;
because there are platforms where it is simply not possible to write a
special
character like 0x0a to flush an output buffer and start a new output line.
On old scientific computers of the 1960s and 1970s, there simply was no
such character;
this comes from the teletype heritage of the Unix operating system. Even
today there
are platforms (and languages) where it is not possible to write a new
line on output
simply by writing a 0x0a char. Only people which have grown up with
systems like
MS-DOS and Unix take this as given.
So I doubt that there is a portable solution for multi-line strings in
the sense that
strings involve carriage-return characters. If you need such things, you
have to find
non-portable solutions (like platform-specific constants:
CONST NL_Number = 0x0a; for example
or CONST NL_CHAR = X'0a'; ... if your compiler allow such a notation).
Second:
To split strings in source programs, I strongly suggest a solution where
the parts are
terminated on every line; otherwise (with strings left open), you will
always have a
problem with trailing and leading blanks. The source code should be
format free,
after all.
The simplest solution IMO is: simply close the string on one line and
open it on the
next one, like here:
CONST long_string = 'this is a long string '
'which occupies '
'multiple source lines';
if you absolutely need to put line feed characters into such a long
string, do it like this:
CONST long_string = 'this is a long string ' x'0a'
'which occupies ' x'0a'
'multiple source lines';
This is implemented in my New Stanford Pascal compiler.
Kind regards
Bernd
Am 04.07.2019 um 13:54 schrieb Michael Van Canneyt:
On Thu, 4 Jul 2019, Tomas Hajny wrote:
On 2019-07-04 12:59, Marģers . via fpc-devel wrote:
.
.
Why introduce ` if there already is ' ? Just use '
as well for multi line strings. For people of more
conservative view point, put multilinestring
behind mode switch.
Because then it's never clear whether the fact that there's no ending
quote before the end of the line is an omission, or an intention.
Exactly. The same goes for all other quote characters. That's why the
directive is a better approach; it is unambigious.
Michael.
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel