strings

Norman Diamond diamond at diamond.csl.sony.junet
Fri May 12 19:43:06 AEST 1989


I wrote:

>>C says that a string is terminated
>>with a '\0' byte.  Instead of assigning a null string to a target,
>>C programmers assign a '\0' byte, so the implementation of C library
>>routines can never be speeded up.  For other languages, improvements
>>are often made to implementations.

In article <1989May11.155935.22324 at utzoo.uucp> henry at utzoo.uucp (Henry Spencer) writes:

>Improvements to C library routines are quite possible.  Like all such,
>cleverness is sometimes required.  One convention is not intrinsically
>worse than the other.

How do you improve a C library routine to look in a string descriptor
to just grab the current length of the string?  In other languages,
libraries can do that.  It kind of seems to me that if a C library
does that, I can watch it break my legal C program.  On the other hand,
a correct strlen() function has to scan every byte of (for example)
my 300K array.  Or my 509-byte array, maybe 510-byte array, but several
thousand times.  It seems intrinsically worse to me.

--
Norman Diamond, Sony Computer Science Lab (diamond%csl.sony.co.jp at relay.cs.net)
  The above opinions are my own.   |  Why are programmers criticized for
  If they're also your opinions,   |  re-implementing the wheel, when car
  you're infringing my copyright.  |  manufacturers are praised for it?



More information about the Comp.lang.c mailing list