-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: split up fs::soft_link into os::unix::fs::symlink and os::windows::fs::{symlink_file, symlink_dir} #1048
RFC: split up fs::soft_link into os::unix::fs::symlink and os::windows::fs::{symlink_file, symlink_dir} #1048
Conversation
Absolutely 👍 from me - being the only ones using the "soft link" terminology seems like a bad idea. |
cc @aturon |
I've pushed a proposed branch to make this change in rust-lang/rust#24222. If one of the alternatives names is selected, I'll update that branch with the chosen alternative. |
Since a big part of the community, including myself, frowns upon abbreviations from 80ies, I 👎 this unless the proposed name is changed to |
I like |
@nagisa I'm curious about your reasoning. I can understand wanting to avoid some really bad legacy abbreviations, like I should be clear that I am also happy with either |
My reasoning usually boils down to two things: it is more natural to read (you don’t need to resolve the abbreviation) and is essentially free when even the most primitive code editors feature some form of autocompletion.
These are supposed to be exceptions, not a rule. Either because they’re used a lot (unlike a function to create a symbolic link), they’re a historical mistake (already! luckily most of these were fixed during the stabilisation) or having it abbreviated was deemed to be superior to the full word by the core team. |
Also |
After some thought on this I think that the precedent elsewhere is a pretty strong motivating factor for the renaming here. We've previously debated the name So I think that the three options for the name of this function would be @nagisa I feel that while "symlink" may technically be an abbreviation for "symbolic link" that the term "symlink" has actually become quite common now and can also be considered to not be an abbreviation. Along those lines it seems even Windows very commonly refers to these as symlinks as well. Also, could you elaborate a little more on why you think it's inconsistent with |
Of the three proposed by @alexcrichton, I find |
+1 to |
If you look at them side by side:
|
After considering this further, I don't think that You can confirm that this interpretation is borne out by common usage by searching Google for "symlink a file", "symbolic link a file", "symbolically link a file", "hard link a file". "Symlink a file", "symbolically link a file", and "hard link a file" are all used as verb phrases, while "symbolic link a file" is not. If you look at the list of what the operation is called in other languages and APIs, every one that uses the full "symbolic link" form has the verb "create";
One more point is that I found that Windows does actually use the term "symlink" in the constant for the reparse point type, |
Interesting observation @lambda. I still don't like In 2nd place is |
While these APIs are already stable and making more breakage than strictly necessary is bad… what about |
I think it is okay to use noun phrases as constructors. For me, |
Why do you call these constructors? Aren't they just functions? |
@tshepang, yeah I should have said "factories/factory functions" (though in a language where constructors are not treated specially, factory functions and constructors are technically the same). |
@lambda given much of the discussion on #1044, I think that this may want to be updated a bit. I think that your suggestion is an excellent one as it strikes a nice balance between:
Would you be ok updating this RFC to reflect that state of affairs? |
As described in the RFC, the differences in how creating symlinks works differs sufficiently between Unix and Windows that trying to have a cross-platform API is a compability hazard.
@alexcrichton Updated the RFC based on the discussion in #1044, suggesting using |
|
||
# Summary | ||
|
||
Rename `std::fs::soft_link` into platform-specific versions: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Deprecate std::fs::soft_link
in favo(u)r of:
I fully support this RFC in its current form. |
Looks great to me, thanks @lambda! |
After this discussion it definitely seems like this is the best direction to go in for now as it provides a nice balance between high-level APIs while following the standard library's principle of forcing confrontation with platform-specific differences. As a result we've decided to accept this, so I"m going to merge it. Thanks @lambda! |
Implement [RFC rust-lang#1048][rfc]. On Windows, when you create a symbolic link you must specify whether it points to a directory or a file, even if it is created dangling, while on Unix, the same symbolic link could point to a directory, a file, or nothing at all. Furthermore, on Windows special privilege is necessary to use a symbolic link, while on Unix, you can generally create a symbolic link in any directory you have write privileges to. This means that it is unlikely to be able to use symbolic links purely portably; anyone who uses them will need to think about the cross platform implications. This means that using platform-specific APIs will make it easier to see where code will need to differ between the platforms, rather than trying to provide some kind of compatibility wrapper. Furthermore, `soft_link` has no precedence in any other API, so to avoid confusion, move back to the more standard `symlink` terminology. Create a `std::os::unix::symlink` for the Unix version that is destination type agnostic, as well as `std::os::windows::{symlink_file, symlink_dir}` for Windows. Because this is a stable API, leave a compatibility wrapper in `std::fs::soft_link`, which calls `symlink` on Unix and `symlink_file` on Windows, preserving the existing behavior of `soft_link`. [rfc]: rust-lang/rfcs#1048
Rendered