On Tue, Oct 28, 2008 at 10:26 AM, Aaron Cooper <[EMAIL PROTECTED]> wrote:
> Let me get this straight: Does all this mean that my\namespace\is\trouble is
> going to end up:
>
> my
> amespace\is rouble
No, it doesn't.
There are only three escape sequences that involve letters that are
also valid in class/namespace identifiers. They are \n, \r and \t.
None of them are interpreted as escape sequences except when they
appear in a double quoted (or heredoc) string.
There are only a few places that PHP accepts the name of a class or
namespace as a string. Mostly, they're where a function accepts a
callback, and you want to pass a static method. That's really the only
place you'll ever have to worry about the namespace separator being a
backslash as opposed to some other character. And it's only a problem
if you use a double quoted string. And, even if all of that holds,
your IDE should really be highlighting the escape sequence for you.
And even if it doesn't, the escape sequence rules are easy to learn,
and familiar to the vast majority of programmers, even from other
languages.
Now, because the tab character, the newline character and the carriage
return aren't valid in identifiers, PHP will either be able to
translate, for example, the tab back into \t, or it could throw a nice
detailed error ("Unexpected tab character in callback string. Bad
escape character?").
As for why they couldn't just use ::, I'd skip reading the confused
and confusing descriptions at rfc/backslashnamespaces and
rfc/namespaceseparator and go straight to the analysis that finally
stated a new separator would be needed: Greg's one, here:
http://wiki.php.net/rfc/namespaceissues
Specifically, the first section named 'The Problem'. It's the most
succinct example of why a namespace separator other than :: is needed.
Dom
--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[EMAIL PROTECTED]
-~----------~----~----~----~------~----~------~--~---