On 3 Aug 2007, at 14:28, David Cantrell wrote:
On Fri, Aug 03, 2007 at 07:23:55AM -0500, Peter da Silva wrote:
On Aug 3, 2007, at 6:47, David Cantrell wrote:
On Thu, Aug 02, 2007 at 02:32:20PM -0500, Peter da Silva wrote:
Please have the length of strings upfront.
Length encoding isn't self-syncing,
Better that than not being able to easily pass arbitrary data, which
might include NULLs.
As parameters to programs that are going to use them in UNIX system
calls?
I want only one kind of string thankyouverymuch.
Sheesh :)
Are we still arguing about program args or am I right in thinking
we've moved on to strings in general?
And if we're rehashing the old 'which string representation is
better' argument do we genuinely believe it to be a burning issue -
or are we just doing the dance for nostalgic reasons?
I recall an editorial in either Byte or PCW about the time it first
seemed likely that C would displace Pascal as the hot language de-
jour. The gist was that it'd never be possible to write a decent text
editor in C because of the need to constantly scan to the end of the
text to find out how big it was. Duh.
Yes it's miserable to consider how many cycles have been wasted
chasing down nulls over the years and to contemplate all the extant O
(N^2) loops that call strlen() for every character processed - but C
strings have advantages over Pascal style counted strings in other
ways: the fact that characters can be dropped from the front of the
string just by advancing the pointer is a huge win in a lot of
situations. With Pascal strings a function that trims leading spaces
has to return a new string - with C strings you just return a pointer
that has advanced past the whitespace. Makes it much easier to write
parsers &c.
Counted strings make sense when you have plenty of memory and garbage
collection; in more primitive languages they're a pain.
--
Andy Armstrong, hexten.net