Sujet : Re: The joy of FORTRAN
De : antispam (at) *nospam* fricas.org (Waldek Hebisch)
Groupes : alt.folklore.computers comp.os.linux.miscDate : 30. Sep 2024, 13:35:48
Autres entêtes
Organisation : To protect and to server
Message-ID : <vde5v2$fg8s$1@paganini.bofh.team>
References : 1 2 3 4 5 6 7 8 9
User-Agent : tin/2.6.2-20221225 ("Pittyvaich") (Linux/6.1.0-9-amd64 (x86_64))
In alt.folklore.computers Peter Flass <
peter_flass@yahoo.com> wrote:
Another thing PL/I got from COBOL is “natural” string handling. Assign a
short string to a larger any the result is automatically blank-padded.
Assign a longer to a shorter and the longer is truncated, with or without
an error.
In my world blank padding is simply wrong result. Truncation too.
To have natural handling language needs to track actual lengths
(and signal (catchable) error on overflow). And such natural
handling may be quite inefficient. I recently looked at code
generated by GNU Pascal compiling for a 32kB machine. String
handling needed about 60kB for string buffers (30 buffers 2kB
each) and the file did not compile. Compiler handling string
buffers in smarter way probably could reuse some buffers.
But there were several copy operations (or rather concatenations)
and some string variables were used multiple times, so even
with good optimizer for string operations the code would still
be rather inefficient.
To put it differently: natural string operations work nicely
if you have big machine with lot of memory and machine cycles
to waste. But if you need efficient code for small machine,
then you want single buffer which is modified in place.
And of course, on big modern machines people use dynamic memory
allocation.
-- Waldek Hebisch