# Identifier starting with decimal digit

**URL:** <https://internals.rust-lang.org/t/identifier-starting-with-decimal-digit/17555>\
**Category:** language design\
**Created:** [October 13, 2022, 3:37pm UTC](https://internals.rust-lang.org/t/identifier-starting-with-decimal-digit/17555 "2022-10-13T15:37:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hydroper1](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/hydroper1/32/12099_2.png) [@hydroper1](https://internals.rust-lang.org/u/hydroper1)\
**Post date:** [October 13, 2022, 3:37pm UTC](https://internals.rust-lang.org/t/identifier-starting-with-decimal-digit/17555/1 "2022-10-13T15:37:53Z")

</div>

Why is `r#3D_CONSTANT` not allowed?

```rust
fn main() {
    let r#0 = 10;
}

```

Error:

```rust
error: found invalid character; only `#` is allowed in raw string delimitation: 0

```

---

<div class="post-metadata">

**Author:** ![Nemo157](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/nemo157/32/11585_2.png) [@Nemo157](https://internals.rust-lang.org/u/Nemo157)\
**Post date:** [October 13, 2022, 3:46pm UTC](https://internals.rust-lang.org/t/identifier-starting-with-decimal-digit/17555/2 "2022-10-13T15:46:18Z")

</div>

The only affect `r#` has is to stop an identifier being parsed as a keyword (except some special keywords it appears, I didn't realise it had some limitations), it doesn't change the allowed syntax. [Identifier syntax](https://doc.rust-lang.org/nightly/reference/identifiers.html) doesn't allow a digit in the first position.

There was [some discussion in the RFC](https://rust-lang.github.io/rfcs/2151-raw-identifiers.html#rationale-and-alternatives) of an even more lenient syntax that would drop all restrictions and allow using even things like spaces in an identifier. IIRC the reason this wasn't done is that it's not necessary for the main motivation, which is allowing editions to reserve new keywords and still have code interoperate between editions.

---

<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:** [January 11, 2023, 3:47pm UTC](https://internals.rust-lang.org/t/identifier-starting-with-decimal-digit/17555/3 "2023-01-11T15:47:16Z")

</div>

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