On 2005-04-08, CBFalconer <cbfalconer@[EMAIL PROTECTED]
> wrote:
> Marco van de Voort wrote:
>> On 2005-04-08, Scott Moore <scott.moore6@[EMAIL PROTECTED]
> wrote:
>> than either in padded or zero terminated form?
>
> They are more expensive in memory allocation. Many moons ago I was
> using one of the Turbos and I had a recursive routine that included
> some string manipulation. It didn't even declare any string
> variables. It proceeded to crash the system with a stack overflow.
How? If I declare a string everywhere where I would normally do an array
of char, and pass by ref, how could this happen?
Of course, if you pass large constants by value, you get stack overflows.
But
that is an user error. Same for temps, if I do actions on a too high
level,
I'll need temps.
Admitted, in ansi-iso (or M2 notation, which I'm more used too than
ansi-iso) you have to declare the temps, but the principle remains the
same.
> I disagree that length is needed in most string operations.
> Compares, writes, and most copies can just start at the beginning
> and go on until the end. Nul terminated strings do very well for
> this sort of operation. Concatenation is an exception.
E.g. on a x86 compare is typically done by a rep cmpsb which needs length,
same with copy. C char *'s are slow because, in a comparison case, have to
check each character once for the comparison, once _each_ for zero.
Of course the compiler builders went through a lot of trouble to try to
speed this up, but that is brute force, not elegance.
p.s. I miss ansi-iso strings in the equation. How expensive is a lenght()
on
a 7185 "string" ?


|