Path: utzoo!attcan!uunet!kddlab!titcca!sragwa!wsgw!socslgw!diamond!diamond From: diamond@diamond.csl.sony.junet (Norman Diamond) Newsgroups: comp.lang.c Subject: Re: strings Message-ID: <10245@socslgw.csl.sony.JUNET> Date: 12 May 89 09:43:06 GMT References: <2846@tank.uchicago.edu> <5785@cbnews.ATT.COM> <10087@smoke.BRL.MIL> <1415@uw-entropy.ms.washington.edu> <17333@mimsy.UUCP> <10228@socslgw.csl.sony.JUNET> <10237@smoke.BRL.MIL> <10235@socslgw.csl.sony.JUNET> <1989May11.155935.22324@utzoo.uucp> Sender: news@csl.sony.JUNET Reply-To: diamond@csl.sony.junet (Norman Diamond) Organization: Sony Computer Science Laboratory Inc., Tokyo, Japan Lines: 27 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@utzoo.uucp> henry@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@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?