Skip to content
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

Merged
merged 4 commits into from
Apr 17, 2015

Conversation

lambda
Copy link
Contributor

@lambda lambda commented Apr 9, 2015

@andrew-d
Copy link

andrew-d commented Apr 9, 2015

Absolutely 👍 from me - being the only ones using the "soft link" terminology seems like a bad idea.

@lambda
Copy link
Contributor Author

lambda commented Apr 9, 2015

cc @aturon

@lambda
Copy link
Contributor Author

lambda commented Apr 9, 2015

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.

@nagisa
Copy link
Member

nagisa commented Apr 9, 2015

Since a big part of the community, including myself, frowns upon abbreviations from 80ies, I 👎 this unless the proposed name is changed to symbolic_link.

@tshepang
Copy link
Member

tshepang commented Apr 9, 2015

I like sym_link

@lambda
Copy link
Contributor Author

lambda commented Apr 9, 2015

@nagisa I'm curious about your reasoning. I can understand wanting to avoid some really bad legacy abbreviations, like creat or S_ISGID, but much of Rust style involves abbreviations (fn, mut, Vec, str, ptr, mem, create_dir, etc). What about an abbreviation being from the 80s and widely known makes it worse than many of the abbreviations already used in the language or standard library?

I should be clear that I am also happy with either symbolic_link or sym_link if people prefer one of those, I just picked symlink for the main proposal since it does seem to be the most common term and does seem to be well enough known.

@nagisa
Copy link
Member

nagisa commented Apr 9, 2015

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.

much of Rust style involves abbreviations (fn, mut, Vec, str, ptr, mem, create_dir

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.

@nagisa
Copy link
Member

nagisa commented Apr 9, 2015

Also symlink is not consistent with hard_link and read_link.

@alexcrichton
Copy link
Member

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 sym_link but rejected it due to the fact that it is not a commonly used term and the phrase "symlink" is the actual term and not super separable.

So I think that the three options for the name of this function would be symlink, soft_link, or symbolic_link. I personally lean towards symlink for the reasons outlined in this RFC (e.g. it may not actually be unix specific).

@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 hard_link and read_link? The term "hard link" seems to be more widely accepted than "soft link" and I'd be ok with the "link" part of "read link" implying a symbolic link otherwise.

@seanmonstar
Copy link
Contributor

Of the three proposed by @alexcrichton, I find symbolic_link the best.

@liigo
Copy link
Contributor

liigo commented Apr 10, 2015

+1 to symbolic_link (alongside hard_link). (symlink has too much unix feel.)

@nagisa
Copy link
Member

nagisa commented Apr 10, 2015

Also, could you elaborate a little more on why you think it's inconsistent with hard_link and read_link?

If you look at them side by side:

  • hard_link
  • read_link
  • symlink

symlink stands out like a sore thumb being the only abbreviated word and not having _. I strongly believe there will be a great many people complaining about that if we go with symlink.

@lambda
Copy link
Contributor Author

lambda commented Apr 11, 2015

After considering this further, I don't think that symbolic_link makes sense, as it is a noun, not a verb. The verb would be symbolically_link, while hard_link is grammatical as either a noun or a verb. symlink, on the other hand, acts as either a noun or a verb. Since this is the name for a function creating a symbolic link, it should be a verb.

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"; CreateSymbolicLink, createSymbolicLinkAtPath:withDestinationPath:error:, createSymbolicLink.

read_link is a valid verb phrase, hard_link is as well, symbolic_link is not. To make this a verb, you would need to name it something like create_symbolic_link, which is fairly cumbersome; and then, to be consistent, you would probably want to rename hard_link to create_hard_link.

One more point is that I found that Windows does actually use the term "symlink" in the constant for the reparse point type, IO_REPARSE_TAG_SYMLINK.

@tshepang
Copy link
Member

Interesting observation @lambda. I still don't like symlink, for it breaks the Rust naming practices of separating words with underscores. So I vote for sym_link, though @alexcrichton mention a dislike for it.

In 2nd place is soft_link. I don't like symlink for reasons @nagisa gave, but it's better than symbolic_link. symbolically_link is just ridiculous.

@nagisa
Copy link
Member

nagisa commented Apr 12, 2015

While these APIs are already stable and making more breakage than strictly necessary is bad… what about link_hard, link_symbolic and read_link?

@CloudiDust
Copy link
Contributor

I think it is okay to use noun phrases as constructors. channel, for example.

For me, sym_link, symbolic_link, soft_link are all okay, but symlink is not.

@tshepang
Copy link
Member

Why do you call these constructors? Aren't they just functions?

@CloudiDust
Copy link
Contributor

@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).

@alexcrichton
Copy link
Member

@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:

  • Creation of symlinks is clearly platform-specific, and each platform will have clear documentation explaining why/why not it is available.
  • The name of the functions remain "rustic" with symlink
  • All other functionality like read_link or is_symlink (to be added) remain in the right cross platform location (std::fs).

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.
@lambda
Copy link
Contributor Author

lambda commented Apr 14, 2015

@alexcrichton Updated the RFC based on the discussion in #1044, suggesting using symlink as the conventional name, and the platform-specific split.

@lambda lambda changed the title RFC: rename soft_link to symlink RFC: split up fs::soft_link into os::unix::fs::symlink, os::windows::fs::symlink_file, and os::windows::fs::symlink_dir Apr 14, 2015
@lambda lambda changed the title RFC: split up fs::soft_link into os::unix::fs::symlink, os::windows::fs::symlink_file, and os::windows::fs::symlink_dir RFC: split up fs::soft_link into os::unix::fs::symlink and os::windows::fs::{symlink_file, symlink_dir} Apr 14, 2015

# Summary

Rename `std::fs::soft_link` into platform-specific versions:
Copy link
Member

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:

@nagisa
Copy link
Member

nagisa commented Apr 14, 2015

I fully support this RFC in its current form.

Clarify in the summary that we are deprecating `soft_link` rather than
removing it outright, and fix a reference to `softlink`.
@alexcrichton
Copy link
Member

Looks great to me, thanks @lambda!

@alexcrichton
Copy link
Member

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!

@alexcrichton alexcrichton merged commit 9f1ab34 into rust-lang:master Apr 17, 2015
alexcrichton added a commit to alexcrichton/rust that referenced this pull request Apr 21, 2015
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
@Centril Centril added A-file Proposals relating to file systems. A-platform Platform related proposals & ideas A-unix Proposals relating to UNIX. A-windows Proposals relating to Windows. labels Nov 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-file Proposals relating to file systems. A-platform Platform related proposals & ideas A-unix Proposals relating to UNIX. A-windows Proposals relating to Windows.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants