Skip to content

Proposal: Reserve double underscore for nefarious purposes. #1716

Closed
@icefoxen

Description

@icefoxen

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions