[Info-vax] Whither VMS?
glen herrmannsfeldt
gah at ugcs.caltech.edu
Sun Oct 4 23:43:48 EDT 2009
Michael Kraemer <M.Kraemer at gsi.de> wrote:
< Jordi Guillaumes i Pons schrieb:
<> En/na glen herrmannsfeldt ha escrit:
<>> < And one of the first languages that I used that had this "length byte"
<>> < concept was UCSD-Pascal. Which, from the very start, included a way
<>> < to violate those bounds. Go figure....
<>> PL/I also usually uses length at the beginning.
<> Yup! Only for VARYING CHAR variables. On the other hand, it uses
<> descriptors to pass string parameters so the called procedure knows the
<> length of the incoming string, being it fixed-length or varying.
< So does C, thanks to null termination of read-only strings.
< As for target strings, PL/I isn't any better, IMHO,
< unless the standard has changed in the past 15 years.
< They have a maximum length, if you exceed it on write, you'll
< have a buffer overflow as well. Unless you have enabled
< STRINGSIZE, of course, but this is rarely the case in
< production code. And even if it is, what do you gain?
< A production program which aborts due to STRINGSIZE raised.
I forget know whether STRINGSIZE defaults to enabled or not.
It is easy to enable if needed, either for the procedure or
by the statement. It is much more difficult in C to add the
check to a program not designed for it.
< A solution superior to C would be if PL/I allowed stuff like
< DCL AA,BB,CC CHAR(*) VAR;
< CC = AA || BB;
< with automatic (re)allocation of CC with just the right length,
< thanks to the descriptor concept.
< Wasn't possible at the time I had to leave PL/I.
Not automatic, but still probably easier than doing the right
thing in C. Deallocate if needed, allocate to length(aa)+length(bb),
assign.
<> The more recent versions support C-isms like UNION, so the need to do
<> such idioms (when you have to debug a program where one structure is
<> based on the address of the last byte of another structure, which is
<> based on a record, which is based on a POINTER, using a DUMP, you start
<> to wonder what in #??$@ was thinking the programmer about... ;)).
< You don't need unions to mess up your programs.
< The PL/I concept of BASED variables does that as well.
< You can trash just everything, including your oh-so-secure descriptors.
< I remember using this "trick" deliberately to modify the dimension
< layout of array.
< Add to that that PL/I passes arguments by reference (not by
< value, as does C), and you have another possibility of
< trashing data.
Well, arrays, strings, and structures are passed by descriptor.
It might be that VALUE has been added now for calls to C.
-- glen
More information about the Info-vax
mailing list