Re: Null-terminated strings: the final analysis.
- From: Mark McIntyre <markmcintyre@xxxxxxxxxxxxxxxxxxx>
- Date: Sun, 12 Apr 2009 09:22:20 +0100
On 12/04/09 05:06, Tony wrote:
"Bartc"<bartc@xxxxxxxxxx> wrote in message
news:CFusl.4007$Lc7.1359@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
"Tony"<tony@xxxxxx> wrote in message
news:vsnsl.13862$W06.5350@xxxxxxxxxxxxxxxxxxxxxxx
Null terminated strings are premature optimization when considered inThis was discussed here recently, quite extensively too.
modern times. Null-terminated strings are baggage and C suffers from
holding on to this obsolete implementation. (No question here, just
wondering now why a computer programming language should age like a
person?). Comments welcome of course.
And they are not just a C thing, they were and are used ubiqitously
elsewhere, very successfully.
Your alternatives I recall would not fit easily into the low-level C
model.
"easily" is a subjective term, so your thought needs qualification to be
understood. I have a R&D design where a one-character string is one byte
(read no overhead),
What tells you it is one byte? Is it a special type ?
If so, er, isn't that called "char" in C?
small (Pascal) strings have one byte of overhead (the
length) and larger size strings have a few bytes more (but so what? they're
larger strings!). The usage though is via one abstraction.
FYI byte-counted strings aren't new and predate pascal - webearch for Hollerith string.
As criteria for string implementation analysis, I see: space efficiency,
time efficiency, practical usage (usage patterns are much different now than
then and the std implementation may be/may have impeding/impeded progress),
Some of the above may be true - C++ and Java use a form of byte-counted string. However note that C's model is likely to be the most space-efficient for non-trivial sized string, as the storage need be only one byte longer than the string, whereas byte-counted strings must be at least one byte longer.
--
Mark McIntyre
CLC FAQ <http://c-faq.com/>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
.
- Follow-Ups:
- Re: Null-terminated strings: the final analysis.
- From: David Thompson
- Re: Null-terminated strings: the final analysis.
- From: Tony
- Re: Null-terminated strings: the final analysis.
- From: Mark Wooding
- Re: Null-terminated strings: the final analysis.
- References:
- Prev by Date: Re: Null-terminated strings: the final analysis.
- Next by Date: Re: structure and union queries
- Previous by thread: Re: Null-terminated strings: the final analysis.
- Next by thread: Re: Null-terminated strings: the final analysis.
- Index(es):
Relevant Pages
|