3 ms·
Backspace would be amazing in Rust. Imagine: use .\greetings\hello; use ..\foo; use \bar; right now these are: use self::greetings::hello;
by iopq 10y ago
Backspace would be amazing in Rust. Imagine:
use .\greetings\hello;
use ..\foo;
use \bar;
right now these are:
use self::greetings::hello;
use super::foo;
use ::bar;
I think the PHP way would have been way better
- kbenson 10y agoBackslash is almost universally associated with "escaping" the next character in a string. The only place I've ever seen it used as a separator is in Windows, and my understanding is that it causes enough grief when used in strings that people dislike it there as well. The only reason Windows uses backslash is because DOS 1.0 didn't have hierarchies and already used slash for command switches, so they used backslash so it wouldn't conflict. What is wrong with ::? It's visually distinct, isn't easily confused for other things, and unused for anything else, which pretty much hits all the criteria I care about for this feature. I'm seriously asking, why do people dislike ::? Is there an actual basis, or do people just not like the look?
- iopq 10y agoThose paths are actually valid Windows paths. I don't like `super` and `self` instead of `..` and `.` - it's just extra stuff to remember. Also, because of how the metaphor for paths is broken, the relative paths in Rust are not intuitive. That's why you HAVE TO put `self::foo` because the default is not the same as what you'd expect if it were a path. It's overly complicated compared to just letting you use actual Windows paths.
- kbenson 10y agoExcept not everyone uses Windows. Why not a regular slash instead of a backslash since even on Windows they sometimes allow that since it's standard for the web? Because modules and namespaces don't always correspond to files. Having the namespace separator be the same as a file path separator may imply a connection to the the filesystem hierarchy which does not exist, or is far removed.
- iopq 10y ago> Why not a regular slash because how do you parse let x = a/foo(); is that a::foo() or a / foo()? If you use \ it's unambiguous, a\foo() corresponds to a::foo() while a/foo() is division
- kbenson 10y agoExactly. Forward slash has problems. Backslash has problems. Associating the concept with file paths too much has problems (depending on the language and the module implementation). So, why again is :: such a bad choice, given all this?
- iopq 10y agoBackslash does not have problems. It's a single character and looks like windows paths. :: is two characters and is only familiar for C++ programmers (and means something else in PHP)
- kbenson 10y agoBackslash is the single most problematic visible character to represent in lower ASCII. It's the go-to solution for representing the non-visible characters when you need them in a string representation in most languages I can think of. Many errors have been found in string handling routines because of incorrect escape handling. I wouldn't willingly use it as a special character in any language I had input in designing. Even for windows paths, backslash has caused a lot of problems in various tools[1][2][3]. Just google "backslash path error" for many pages of problems. Even early DOS developers weren't happy with the need for backslash, and made regular slashes work in paths. That doesn't work everywhere in Windows, but it works in a lot of places. Following Microsoft's mistake because of an accident of history (they has already used forward slash for command flags before implementing path hierarchies so needed a different character) and dealing with the same problems they have is not a point in backslash's favor. > :: is two characters and is only familiar for C++ programmers It's familiar for whoever learns it for the language they are learning. That it does not necessarily have an association with concepts from other languages or systems that don't apply cleanly (such as the namespace corresponding to the path, which may not be true) is a positive. 1: https://pythonconquerstheuniverse.wordpress.com/2008/06/04/gotcha-%E2%80%94-backslashes-in-windows-filenames/ https://pythonconquerstheuniverse.wordpress.com/2008/06/04/g... 2: https://github.com/rstudio/shiny/issues/1009 https://github.com/rstudio/shiny/issues/1009 3: http://www-01.ibm.com/support/docview.wss?uid=swg21635233 http://www-01.ibm.com/support/docview.wss?uid=swg21635233