Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upSupport underscores as constant names #2526
Conversation
Centril
added
the
T-lang
label
Aug 20, 2018
This comment has been minimized.
This comment has been minimized.
ExpHP
commented
Aug 20, 2018
|
Alternatives section looks barren. I know some ink has been spilt in the past on the alternative of unnamed modules ( IIRC, one of the primary arguments against that was that hygienic |
This comment has been minimized.
This comment has been minimized.
Good call; I'll add that. Do you know where said ink was spilled so I can link to it?
How would that work? |
This comment has been minimized.
This comment has been minimized.
|
@joshlf |
This comment has been minimized.
This comment has been minimized.
|
Declarative macros are unstable and way bigger than this proposal. That also forces you to use a macro when you could just be doing some compile-time assertions by hand or through a I'm in favour of this proposal. |
This comment has been minimized.
This comment has been minimized.
mcarton
commented
Aug 21, 2018
|
How about supporting all irrefutable patterns in a similar way to const (foo, bar): (T, U) = computeFooAndBar(); |
This comment has been minimized.
This comment has been minimized.
joshlf
force-pushed the
joshlf:joshlf/const-wildcard
branch
from
74e8d80
to
be40ba7
Aug 21, 2018
This comment has been minimized.
This comment has been minimized.
|
This seems reasonable to me. |
This comment has been minimized.
This comment has been minimized.
upsuper
commented
Aug 22, 2018
|
Another alternative is to support unnamed fn like |
joshlf
force-pushed the
joshlf:joshlf/const-wildcard
branch
from
be40ba7
to
6e5ef11
Aug 23, 2018
This comment has been minimized.
This comment has been minimized.
Added to the Alternatives section. |
Centril
self-assigned this
Aug 30, 2018
This comment has been minimized.
This comment has been minimized.
|
@rfcbot merge We discussed the RFC on this week's language team meeting. The general consensus was that we should do this. The proposal seems small in scope, is readily implementable, and it would be useful in some cases (e.g. those mentioned in the motivation, particularly wrt. custom derive macros). It also seems to me that the meaning would be understandable given that I would personally like us to go further in the future to generally allow irrefutable patterns so that you can write |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Aug 30, 2018
•
|
Team member @Centril has proposed to merge this. The next step is review by the rest of the tagged teams:
No concerns currently listed. Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
rfcbot
added
proposed-final-comment-period
disposition-merge
labels
Aug 30, 2018
This comment has been minimized.
This comment has been minimized.
|
Is there a reason to only allow this for |
This comment has been minimized.
This comment has been minimized.
|
@Havvy How would it work for I think |
This comment has been minimized.
This comment has been minimized.
|
No, it wouldn't make sense for any item other than But looking at |
This comment has been minimized.
This comment has been minimized.
|
@Havvy Right, in the case of |
rfcbot
added
the
final-comment-period
label
Sep 27, 2018
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Sep 27, 2018
|
|
rfcbot
removed
the
proposed-final-comment-period
label
Sep 27, 2018
This comment has been minimized.
This comment has been minimized.
|
If the only purpose of this is to create an anonymous top-level scope, it kind of seems like a hack.[1] Especially since you have to give the underscore a "type" of If the goal is to have a facility for scopes at the top level, perhaps we should... just allow curly-braced scopes at top level? [1] If consts could be declared with patterns, this could also be useful in the following code: const fn foo() -> (i32, i32) { /* ... */ }
const (X, _): (i32, i32) = foo();But that doesn't work today even with identifiers. |
durka
reviewed
Oct 4, 2018
|
|
||
| Allow assigning to `_` when defining a new constant. Just like `let _`, this | ||
| doesn't introduce any new bindings, but still evaluates the rvalue at compile | ||
| time like any other constant. |
This comment has been minimized.
This comment has been minimized.
durka
Oct 4, 2018
Contributor
A guide-level explanation does not include the word "rvalue", IMO. And this doesn't explain what the point of the feature is.
This comment has been minimized.
This comment has been minimized.
joshlf
Oct 4, 2018
Author
Contributor
Is there a phrase you'd suggest instead of "rvalue"?
The point of the feature is described in the "Motivation" section.
This comment has been minimized.
This comment has been minimized.
Havvy
Oct 4, 2018
Contributor
What C and C++ call an rvalue, we call a value expression. See the reference on this.
This comment has been minimized.
This comment has been minimized.
Centril
Oct 5, 2018
Contributor
I think we've called it rvalue for some time as well.. see https://github.com/rust-lang/rfcs/blob/master/text/1414-rvalue_static_promotion.md.
This comment has been minimized.
This comment has been minimized.
rkruppe
Oct 5, 2018
Member
We used to call it rvalue, but we've wisened up since then. Likewise with lvalues (now places).
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@durka As you suggest, the idea is that this is the first step on the way towards fully-general patterns like |
rfcbot
added
the
finished-final-comment-period
label
Oct 7, 2018
rfcbot
removed
the
final-comment-period
label
Oct 7, 2018
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Oct 7, 2018
|
The final comment period, with a disposition to merge, as per the review above, is now complete. |
Centril
referenced this pull request
Oct 8, 2018
Open
Tracking issue for RFC 2526, "Support underscores as constant names" #54912
Centril
merged commit cbbc5a7
into
rust-lang:master
Oct 8, 2018
This comment has been minimized.
This comment has been minimized.
|
Huzzah! This RFC has been merged! Tracking issue: rust-lang/rust#54912 |
This comment has been minimized.
This comment has been minimized.
matthiaskrgr
commented
Oct 8, 2018
|
The |
This comment has been minimized.
This comment has been minimized.
|
@matthiaskrgr you know it takes a few seconds to change the URL and everything; I'm not a bot =P |
This comment has been minimized.
This comment has been minimized.
matthiaskrgr
commented
Oct 8, 2018
•
|
Ooh, sorry! |
joshlf commentedAug 20, 2018
•
edited by Centril
Allow the syntax
const _: TYPE = VALUE, analogous tolet _ = VALUE.Rendered
Tracking issue
Discussion on internals here.