[Info-vax] C... the only winning move is not to play...
David Froble
davef at tsoft-inc.com
Fri Feb 14 22:46:46 EST 2014
Paul Sture wrote:
> On 2014-02-11, David Froble <davef at tsoft-inc.com> wrote:
>> VAXman- @SendSpamHere.ORG wrote:
>>
>>> It would all have been in
>>> Macro if it were up to me but the customer said they can only read C.
>>>
>> They lie! I submit that anyone can read BASIC, but I do recall some
>> almost successful instances of trying to make it unreadable.
>>
>> Throughtout this whole thread I've seen in my head:
>>
>> A$ = B$ + C$ + D$ + E$ + F$ + G$ + H$ + I$ + J$ + K$ + L$ + ....
>>
>> Basic, a language that knows how to work with strings ....
>>
>> And no, I don't normally declare my variables ....
>
> There are times when BASIC dynamic strings carry too much of an overhead
> though. I distinctly recall someone here about a decade ago (Shane Smith?)
> describing how he had got much improved performance by massaging some BASIC
> to use static strings rather than dynamic ones.
>
> --
> Paul Sture
Well, work is work. If it must be done, then it's going to have a cost.
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 example, a dynamic string can be 1 byte, and then set equal to a
string 32767 bytes in length, and you don't have to do any special
programming to do that.
So as always, "it depends". If you really need dynamic strings, then
Basic provides them in a very easy to use method. The compiler and RTL
do the work for you. (Isn't that what they are there for?)
If your task can use fixed length strings, then you'll cut out some of
the overhead.
I will observe that it would be rare to have string manipulation in a
loop that executes thousands (or more) times. But it can happen.
More information about the Info-vax
mailing list