Re: Vanishing backslash
On 3/19/2011 12:22 AM, Roedy Green wrote:
On Sat, 12 Mar 2011 06:54:08 +1100, "Qu0ll"<Qu0llSixFour@gmail.com>
wrote, quoted or indirectly quoted someone who said :
expression.replace(".", "\\.");
Replace is a nest of inconsistency. I would love to rip all methods
out with the word "replace" embedded in the name, and rename them
consistently so that there was no ambiguity if regexes were involved
and if it meant first or all. But it is too late now. We have to live
with this mess.
(Shrug.) Get over it.
Have a look at the Javadoc for String.replace. It is a gotcha.
Both replace() methods of java.lang.String look straightforward
to me. Perhaps I've been gotcha'ed.
In a project such as Java, there should be a naming czar to ensures
things are consistently named, parms are in consistent order, and
things that have nothing to do with each other do not share the same
name.
How in the world could this work? The first two goals might be
achievable in a small project with no more than, say, half a dozen
programmers--but only for Version 1.0, after which compatibility
issues constrain the freedom to undo infelicitous choices. The third
goal is a non-starter unless you give up on the idea of borrowing names
from natural languages. "String" is a thin cord, "Thread" is an even
thinner one, "File" is a hand tool for abrading a workpiece, and so on.
Since your own personal last name is overloaded (and your web site's
design demonstrates your awareness of the overload), the futility of
"one concept, one word" should be fairly plain.
--
Eric Sosman
esosman@ieee-dot-org.invalid