3 ms·
That's \ inside of paths and strings. Nothing to do with \ used in a language. Nobody has an issue with \ used in PHP. The only problem is maybe pasting code on
by iopq 10y ago
That's \ inside of paths and strings. Nothing to do with \ used in a language. Nobody has an issue with \ used in PHP. The only problem is maybe pasting code on a blog or something, not really a problem when programming in PHP.
- kbenson 10y agoEverything eventually gets represented by a string somewhere. Paths aren't inherently strings, but that's how they are often represented in code. You won't be defining your namespaces as a string in normal usage, but some things do need oto represent source, so why choose a character that makes their jobs harder. There are parallels. It's a downside of using backslash. It's not guaranteed to cause a problem, but the potential is there and waiting for anyone that needs to deal with representing it in language.
- iopq 10y agoBy string, I of course speak of string literals. The only place where this would be an issue is writing Rust compiler error messages. I don't consider that a strong argument for why the path analogy should be broken. Because the path analogy is broken, modules in Rust have strange rules. For example, use foo::bar; doesn't actually use a relative "path" from the current module you need to use use self::foo::bar; I think this is a confusing default, and it would have never ended up this way if Rust used Windows-path-looking namespace syntax if you're writing a parser and manipulating actual arrays of bytes, you don't have an issue with backslash, it's just another character to you