[Info-vax] String handling, was: Re: C... the only winning move is not to play...
VAXman- at SendSpamHere.ORG
VAXman- at SendSpamHere.ORG
Sat Feb 15 08:27:45 EST 2014
In article <ldnnn6$ji6$1 at dont-email.me>, Simon Clubley <clubley at remove_me.eisner.decus.org-Earth.UFP> writes:
>On 2014-02-14, David Froble <davef at tsoft-inc.com> wrote:
>>
>> Basic supports various types of strings, dynamic, fixed length,
>> constants, MAPs, and so forth.
>>
>> Yes, if you declare a static string, that's there, nothing more to do
>> except move data in and out.
>>
>> A dynamic string, every time it's set, must determine whether the
>> current storage can be used, and if not, (I'm guessing a bit here),
>> deallocate the current storage and allocate new storage of the desired
>> length. I heard once that if the new string is smaller, it uses the
>> same storage, but, I'm not sure then how it knows that the storage is
>> longer than the current string.
>>
>
>For comparison, Ada has a half-way datatype, between fixed length and
>fully dynamic strings, called Bounded_String in which space up to a
>maximum length is pre-allocated but it's otherwise treated as a
>dynamic string.
That's a fixed length string in my view. Think VMS string descriptor here.
The storage is allocated to the amount bounded and that memory is made the
pointer in the descriptor. The only thing then that changes is the length.
In a dynamic string, the pointer will change to memory allocated on the fly
to house the data of the indicated length. In an OpenVMS descriptor, both
the length and the pointer will vary.
Ada's bounding of strings and arrays is a nice language feature to insure
one doesn't overreach and overwrite the object, but it's simply application
of the VAX INDEX instruction operation.
--
VAXman- A Bored Certified VMS Kernel Mode Hacker VAXman(at)TMESIS(dot)ORG
Well I speak to machines with the voice of humanity.
More information about the Info-vax
mailing list