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?
Arne
On 2/25/2024 4:33 PM, Arne Vajhøj wrote:
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?
I don't know the correct answer, but, at a guess, whatever is called to handle the string quite likely will evaluate the descriptor and do "the
right thing". That would be my bet. Otherwise, why have descriptors?
If I have understood it correctly then VMS Basic strings use class D descriptors.
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?
On 2024-02-25 21:33:33 +0000, Arne Vajhøj said:
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 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.
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.
On 2/26/2024 4:17 PM, Stephen Hoffman wrote:
On 2024-02-25 21:33:33 +0000, Arne Vajhøj said:
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 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.
Basic cannot stuff 200 bytes into a 100 bytes fixed length string. That
is fair.
On Sun, 25 Feb 2024 16:33:33 -0500, Arne Vajhøj wrote:
If I have understood it correctly then VMS Basic strings use class D
descriptors.
The “VAX BASIC User Manual” mentions both dynamic and fixed-length strings. Chapter 13 explains that strings are fixed-length when part of COMMON, MAP or RECORD statements, otherwise they are dynamic. Fixed-length strings obviously cannot have their storage reallocated.
In article <urnggb$3trjg$1@dont-email.me>,
=?UTF-8?Q?Arne_Vajh=C3=B8j?= <arne@vajhoej.dk> wrote:
On 2/26/2024 4:17 PM, Stephen Hoffman wrote:
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 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.
Basic cannot stuff 200 bytes into a 100 bytes fixed length string. That
is fair.
Fortran can! And you likely won't notice that you have damaged some other memory until you get a SIGSEGV in some totally unrelated part of your code.
On 2/26/2024 4:17 PM, Stephen Hoffman wrote:
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.
I would assume that it works as long as the string is considered a
sequence of bytes not a sequence of characters.
I would assume that such code will break in various ways when presented
with UTF-8.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 434 |
Nodes: | 16 (2 / 14) |
Uptime: | 128:21:36 |
Calls: | 9,113 |
Calls today: | 7 |
Files: | 13,422 |
Messages: | 6,031,839 |