-
Notifications
You must be signed in to change notification settings - Fork 605
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
Proposal: Reserve double underscore for nefarious purposes. #1716
Comments
While I'm unsure reserving Would it be something crates.io/cargo have a plan to address? |
@kzys There's been long, vigorous, and often heated discussions about namespacing just about as long as crates.io has been a thing, you can see issue #58 for a representative example. IIRC the canonical response to this is in https://internals.rust-lang.org/t/crates-io-package-policies/1041 , and last I checked the whole crates.io team was justifiably tired of discussing it. I think the way forward for someone who wants namespacing in crates is to make an experimental implementation, make it public for people to use, and see how it goes. This ticket is just an idea for reserving a token for forward compatibility. |
Note that there are no plans for crates.io to ever offer private crates. Its purpose is to be the registry for open-source crates. |
according to Manishearth/namespacing-rfc#2 (comment) there are already crates that use double-underscore or double-hyphen, so I guess this ship has sailed... |
Sure, if you wait a couple years before thinking about something then more counter-examples will occur. |
no need for passive-aggressiveness. if you want to help out, feel free to join the team and participate in the maintenance of crates.io. |
Sorry, just frustrated and wish I had time and energy to do such a thing. |
Basically, I propose disallowing crates with a
__
in their name from being published, reserving that character sequence as a possible escape character or some other such thing in the future. Also, we would get the bonus of being able to use the Python term "dunder" for it.My original thought was allowing an alternate crate registry to use it as a namespace separator while still having identifiers be valid Rust module names, so that someone could ask for crate
icefox/foobar
and it would look up the crateicefox__foobar
and import it as the Rust moduleicefox__foobar
or such, and everyone could be happy, nobody would need to get hurt, and one wouldn't need to contort oneself too much if one wanted to put the same crate on more than one repository.However, if one really wanted one could use an escape character for other things instead, such as an escape character. So you could have a crate "called"
foo@bar
and it would resolve to the Rust identifierfoo__at__bar
or something silly like that. I'm not really sure why you would want to do that, but it would be possible.This would theoretically break any crate that already has a double-underscore in it, or at least make life inconvenient for them, but I find a grand total of one of them,
teardown_tree___treap
, which goes to the luxurious extreme of not only two but three underscores. Or as one might refer to it, a trunder.Sorry, this is poorly explained, and I might have mentioned it before but I can't find an existing issue talking about it. If people are interested and don't immediately shoot this down as being obviously insane I might get around to submitting a PR for it someday.
The text was updated successfully, but these errors were encountered: