3 ms·
The above sounds like a religious statement. What difference does it make that it's a \ over a .? It does what it needs to do.
by asnyder 18y ago
The above sounds like a religious statement. What difference does it make that it's a \ over a .? It does what it needs to do.
- lucumo 18y agoI think most people have internalised the notion of backslash being the escape operator. That's the way it's used in a lot of languages. Using it for something different not only feels dirty, it may also make it harder to get the "feel" (i.e. to quickly recognize and use) of the namespace operator. Maybe that concern is invalid and we'll quickly adjust. Since this is what the PHP folks have decided, we'll soon get the chance to find out.
- asnyder 18y agoIn PHP the backslash is also an escape operator, but only when used within the confines of a string. In this case, you're not within a string, so it shouldn't be confusing. But like you said, we'll soon get the chance to find out.
- vito 18y agoBut you could be. "$foo = "Bar\test"; $foo();" is entirely plausible but doesn't give do what you expect; you need to escape the \.
- lucumo 18y agoAllow me to clarify. I don't mean that it's confusing or ambiguous. What I mean is that the only place people have seen the backslash in their language and many other places is as an escape operator. This means that the backslash - when seen alone - was most likely to be an escape character. When scanning code, you often use "landmarks" to find your way about. This is why indentation is so useful. But this is also used on a smaller level. When seeing a comma, you usually expect to find something else after it, just because that's what you're used to. The same can hold for backslashes. Personally, I "feel" that backslashes are an escape character to such a degree that to see one without an escaped item after it, feels like a syntax error. Now, I'm not arguing that this is a terrible choice of the PHP folks - at least we finally get namespaces - but I do understand how some people find the backspace an irritating choice.
- wvenable 18y agoBecause the language already has :: copied from C++. But rather than continuing to use :: for both namespaces and static class access, exactly like it's done in C++, they added yet another operator. To solve a problem that doesn't exist. So rather than simplifying the language, they're making it more complicated (especially by choosing the escape character). It's just dumb.
- jrockway 18y agoWell, to be fair to the implementors, using \ makes the parser slightly easier to implement. Good languages (and libraries) are willing to make implementation harder if it makes the code easier for the user to write. But this is PHP. You seem surprised.
- asnyder 18y agoIf you put it that way, then I would have to agree. But I don't think I would go so far as to fork the language to correct the issue as was suggested above.
- nir 18y agoAlso, it's just bad taste. It's plain ugly. I wish someone would write a PHP parser with a Ruby-like syntax. Obviously the more powerful features of Ruby would still be missing, but just having a more readable syntax would be a nice improvement.