string is rarely useful as a function argument
Walter Bright
newshound2 at digitalmars.com
Fri Dec 30 20:09:33 PST 2011
On 12/30/2011 7:30 PM, Jonathan M Davis wrote:
> Yes, diligent programmers will generally find such problems, but with the
> current scheme, it's _so_ easy to use length when you shouldn't, that it's
> pretty much a guarantee that it's going to happen.
I'm not so sure about that. Timon Gehr's X macro tried to handle UTF-8
correctly, but it turned out that the naive version that used [i] and .length
worked correctly. This is typical, not exceptional.
This was definitely not true of older multibyte schemes, like Shift-JIS
(shudder), but those schemes ought to be terminated with extreme prejudice. But
it definitely will take a long time to live down the bugs and miasma of code
that had to deal with them. C and C++ still live with that because of their
agenda of backwards compatibility. They still support EBCDIC, after all, that
was obsolete even in the 70's. And I still see posts on comp.moderated.c++ that
say "you shouldn't write string code like that, because it won't work on
EBCDIC!" Sheesh!
More information about the Digitalmars-d
mailing list