# Poll: Which other-crate-relative-path syntax do you prefer?

**URL:** <https://internals.rust-lang.org/t/poll-which-other-crate-relative-path-syntax-do-you-prefer/5744>\
**Category:** language design\
**Created:** [August 10, 2017, 12:40am UTC](https://internals.rust-lang.org/t/poll-which-other-crate-relative-path-syntax-do-you-prefer/5744 "2017-08-10T00:40:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![elahn](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/elahn/32/1652_2.png) [@elahn](https://internals.rust-lang.org/u/elahn)\
**Post date:** [August 10, 2017, 12:40am UTC](https://internals.rust-lang.org/t/poll-which-other-crate-relative-path-syntax-do-you-prefer/5744/1 "2017-08-10T00:40:18Z")

</div>

> [@Revisiting modules -- \`\[other\_crate\]::path\` syntax](https://internals.rust-lang.org/t/revisiting-modules-other-crate-path-syntax/5728/31):
>
> I’ve looked through the token list and selected tokens that can be more or less usable for other-crate-relative paths without ambiguities (including “inline” non-`use` paths).
> 
> Most of tokens were thrown away immediately because they can be used as binary/unary operators and they can be used freely with paths in expressions. I tried to not introduce new tokens for this, but in principle `~` can be used regardless of syntax details because it’s unused at the moment, or the backslash token (`\`) can be added to the language (can’t say I’m a fan though).
> 
> There are roughly three groups of possible syntaxes:
> 
> ```rust
> a INFIX b::c
> OPEN_DELIM a CLOSE_DELIM b::c
> PREFIX a::b::c
> 
> ```
> 
> `INFIX` variants look universally bad, IMO, mostly because they break the path into separate parts.
> 
> ```rust
> a _ b::c
> a::_::b::c
> a crate b::c
> a:\b::c // Windows drive letters!
> a#b::c
> a#::b::c
> // etc
> 
> ```
> 
> `OPEN_DELIM a CLOSE_DELIM` variants look better.
> 
> ```rust
> [a]::b::c
> (a)::b::c
> {a}::b::c
> // but not <a>::b::c, it's already taken
> 
> ```
> 
> `PREFIX a::b::c` (1) keywords. From all keywords only `crate`, `extern` and `in` looks somehow relevant.
> 
> ```rust
> // Less noise
> extern a::b::c
> crate a::b::c
> in a::b::c
> // More noise
> extern::a::b::c
> crate::a::b::c
> in::a::b::c
> 
> ```
> 
> `PREFIX a::b::c` (2) sigils, look kinda random.
> 
> ```rust
> _ a::b::c
> _::a::b::c
> #a::b::c
> #::a::b::c
> ~a::b::c
> ~::a::b::c
> 
> ```
> 
> Aaaand… ta-da!
> 
> ```rust
> @a::b::c
> 
> ```
> 
> is not actually ambiguous!11
> 
> `@` can currently be used only in patterns like this `ref? mut? IDENT @ PATTERN and IDENT PATH` is never a valid token sequence, so `ident @a::b::c` is unambiguously a pattern (`ident @ a::b::c == IDENT @ PATTERN`) and not ident `@a::b::c == IDENT PATH`, because the latter is not a valid syntax.

> [@Revisiting modules -- \`\[other\_crate\]::path\` syntax](https://internals.rust-lang.org/t/revisiting-modules-other-crate-path-syntax/5728/32):
>
> Basically, the three most viable syntaxes were already discussed in various threads:
> 
> ```rust
> // The least noisy syntax, and well fitting because `@` has "location" semantics.
> @a::b::c
> 
> // Slightly more noisy syntax, and memorable because `[###]` is a *crate*.
> [a]::b::c
> 
> // The "no sigils" variant, good if `use extern a;` will be used roughly like
> // `extern crate a;` is used now, with "inline" uses being rare. Probably too
> // wordy if used more often (e.g. in every `use` import).
> extern a::b::c
> 
> ```

Note: this poll includes “inline” non-use paths

_Poll ([view on site](https://internals.rust-lang.org/t/poll-which-other-crate-relative-path-syntax-do-you-prefer/5744/1))_

---

<div class="post-metadata">

**Author:** ![phaylon](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/phaylon/32/62_2.png) [@phaylon](https://internals.rust-lang.org/u/phaylon)\
**Post date:** [August 10, 2017, 12:42am UTC](https://internals.rust-lang.org/t/poll-which-other-crate-relative-path-syntax-do-you-prefer/5744/2 "2017-08-10T00:42:49Z")

</div>

I checked `extern a::b::c`, though I’d certainly prefer `extern::a::b::c` because of more regularity across the full path. It’s an extension of `self::` and `super::` to me.

So I vote for the non-listed `extern::cratename::b::c`.

---

<div class="post-metadata">

**Author:** ![phaylon](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/phaylon/32/62_2.png) [@phaylon](https://internals.rust-lang.org/u/phaylon)\
**Post date:** [August 10, 2017, 1:19am UTC](https://internals.rust-lang.org/t/poll-which-other-crate-relative-path-syntax-do-you-prefer/5744/3 "2017-08-10T01:19:24Z")

</div>

I should also note, while `@foo::bar` is not ambiguous, it would make `foo@@bar::Baz` a valid pattern.

---

<div class="post-metadata">

**Author:** ![elahn](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/elahn/32/1652_2.png) [@elahn](https://internals.rust-lang.org/u/elahn)\
**Post date:** [August 10, 2017, 1:19am UTC](https://internals.rust-lang.org/t/poll-which-other-crate-relative-path-syntax-do-you-prefer/5744/4 "2017-08-10T01:19:43Z")

</div>

Sorry, I can’t add it to the poll as \> 5 mins have passed, but a moderator can…Until then, if anyone wants to vote for `extern::a::b::c`, please like @phaylon’s comment

---

<div class="post-metadata">

**Author:** ![ahmedcharles](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/ahmedcharles/32/4041_2.png) [@ahmedcharles](https://internals.rust-lang.org/u/ahmedcharles)\
**Post date:** [August 10, 2017, 7:27pm UTC](https://internals.rust-lang.org/t/poll-which-other-crate-relative-path-syntax-do-you-prefer/5744/5 "2017-08-10T19:27:17Z")

</div>

There isn’t an option for “don’t do this, please”.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [March 25, 2019, 8:28am UTC](https://internals.rust-lang.org/t/poll-which-other-crate-relative-path-syntax-do-you-prefer/5744/6 "2019-03-25T08:28:54Z")

</div>

Closed on March 25, 2019, 8:28am UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
