If I have understood it correctly then VMS Basic strings use class D
descriptors.
That is very nice.
But what happens if non-Basic code call Basic code with a string using
a class S descriptor? For input/read? For output/write?
Does the Basic runtime call some STR$ function that understands the
difference between S and D and handle A properly? Or will I get a
runtime error due to invalid string?
"It depends."
Most everything in most of the traditional languages and in the RTLs
does the right thing with both dynamic and static text strings, though
the app code involved might not. BASIC app code works pretty well here,
absent "heroic" efforts by the app developer.
If the app code assumes a dynamic arriving and gets handed static, the
RTL will either copy it, or space-pad the results into the static, or
the RTL will return a string truncation error. BASIC space-pads into
static string buffers if and as needed. Or truncates with an error.
Apps written in C, C++, BLISS, MACRO32, and probably some others may or
may not do the right thing with descriptors, as these languages can
need to handle descriptors in app code due to the (~lack of) descriptor
support in those languages. (Yes, I well know about dscdef.h,
descrip.h, et al., thanks.) Some devs will use RTL calls, and some use
explicit code.
As for home-grown descriptor code, few apps (nobody?) implements all of
the different sorts of descriptors available. Not outside of the RTL
itself, that is.
Apps expecting to work with dynamic descriptors might fail with the
truncation error as mentioned, and apps expecting to massage static
descriptors directly and not coded sufficiently cautiously around any
arriving dynamic strings can fail with heap and other errors.
Of the common languages, Pascal utilizes a wide variety of descriptors.
Calling into or getting called from Pascal tends to teach much about
descriptors and descriptor usage.
it wouldn't surprise me to learn that BASIC will fail to work correctly
with 64-bit string descriptors, though. Lots of home-grown app code
also won't. I also wouldn't expect the RTLs to work with encodings
other than ASCII and DEC MCS, either. And UTF-8 will fail in the
expected places, and most searching and sorting tends not to be
sensitive to the (written) language used within the text string.
--
Pure Personal Opinion | HoffmanLabs LLC