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

Proposal: Reserve double underscore for nefarious purposes. #1716

Closed
icefoxen opened this issue Apr 12, 2019 · 7 comments
Closed

Proposal: Reserve double underscore for nefarious purposes. #1716

icefoxen opened this issue Apr 12, 2019 · 7 comments

Comments

@icefoxen
Copy link

icefoxen commented Apr 12, 2019

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 crate icefox__foobar and import it as the Rust module icefox__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 identifier foo__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.

@kzys
Copy link
Contributor

kzys commented Nov 8, 2019

While I'm unsure reserving __ is the right mechanism, I think namespacing in crates would be important as Rust gets more traction from corporate users who tend to have a lot of private/in-company crates.

Would it be something crates.io/cargo have a plan to address?

@icefoxen
Copy link
Author

icefoxen commented Nov 8, 2019

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

@carols10cents
Copy link
Member

corporate users who tend to have a lot of private/in-company crates.

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.

@Turbo87
Copy link
Member

Turbo87 commented Feb 11, 2021

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

@Turbo87 Turbo87 closed this as completed Feb 11, 2021
@icefoxen
Copy link
Author

Sure, if you wait a couple years before thinking about something then more counter-examples will occur.

@Turbo87
Copy link
Member

Turbo87 commented Feb 11, 2021

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.

@icefoxen
Copy link
Author

Sorry, just frustrated and wish I had time and energy to do such a thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants