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 upTracking issue for `concat_idents` #29599
Comments
aturon
added
T-lang
B-unstable
labels
Nov 5, 2015
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Relevant blog for future plans: http://www.ncameron.org/blog/untitledconcat_idents-and-macros-in-ident-position/ |
This comment has been minimized.
This comment has been minimized.
|
A solution that has been thrown around on IRC (but never ended up anywhere else AFAIK): macro_rules! wrap {
($name:ident) => { struct concat_idents!!(Wrapped, $name)($name); }
}The "early expansion" If we move towards having all macros produce token streams that are parsed on-demand, such "early expansion" could be used in many more locations without adding macro support for each one. The only disadvantage is that |
This comment has been minimized.
This comment has been minimized.
|
https://github.com/mikkyang/rust-blas uses it for quick notation of FFI functions that follow a certain scheme: https://github.com/mikkyang/rust-blas/blob/master/src/prefix.rs https://github.com/mikkyang/rust-blas/blob/master/src/matrix/ll.rs |
skade
referenced this issue
Dec 1, 2015
Merged
Remove concat_ident! for module expressions, enable building on stable #12
This comment has been minimized.
This comment has been minimized.
|
Well, given that mikkyang/rust-blas#12 is a nicer solution within the current language, I'd also like to raise my hand for "useless". |
This comment has been minimized.
This comment has been minimized.
|
I think we should never stabilise the current version - as others have noted it is useless. |
This was referenced May 24, 2016
This comment has been minimized.
This comment has been minimized.
|
Since this is the tracking issue, other who stumble across it might be interested in https://github.com/SkylerLipthay/interpolate_idents which works on nightly rust. |
This comment has been minimized.
This comment has been minimized.
|
Unfortunately that solution will always depend on nightly Rust (until the day that syntax extensions become stable and pigs fly). |
This comment has been minimized.
This comment has been minimized.
|
Given that the consensus seems to be "useless" and theres nicer solutions (e.g. [1], maybe we can remove this feature? |
This comment has been minimized.
This comment has been minimized.
|
See rust-lang/rfcs#1628. |
This comment has been minimized.
This comment has been minimized.
|
@retep998 yes, just noting it as a stopgap. @skade it's the implementation rather than the idea that's useless. If |
This comment has been minimized.
This comment has been minimized.
|
@aidanhs that still means that we should drop the feature to make sure no one uses it. I agree that my solution doesn't cover all edge-cases, but all uses that I've currently seen in the wild. Also, but this is outside of my competence to decide, I think this is a perfect case for the use of a code generator. |
This comment has been minimized.
This comment has been minimized.
|
@skade afaict nobody can use it, so that's not a big concern...but equally there's no reason to keep it around. My main motivation for leaving it was as a reminder that people do want the functionality, but I'm content to follow the RFC and have changed my position to "I don't mind either way". Regarding use cases, here's the motivating example that brought me to this issue in the first place. Codegen's awesome for things like phf, but it feels a bit like overkill when I just want to generate some repetitive methods to extract tuples from enum variants. I guess it's down to personal preference. |
This was referenced Aug 6, 2016
JelteF
referenced this issue
Feb 21, 2017
Closed
Macros 1.2: Fast-track to stabilize function-like procedural macros #1913
Mark-Simulacrum
added
the
C-tracking-issue
label
Jul 22, 2017
This comment has been minimized.
This comment has been minimized.
|
An amusing fact about the current implementation of
(good luck actually doing anything with it) |
This comment has been minimized.
This comment has been minimized.
Empty string is used as a reserved identifier with special meaning in several places in the compiler, so this can potentially cause issues. |
This comment has been minimized.
This comment has been minimized.
|
The linked RFC has been closed as postponed. Should |
This comment has been minimized.
This comment has been minimized.
|
The RFC should be reopened. It never should have been closed, as no better solution was proposed. |
This comment has been minimized.
This comment has been minimized.
|
@durka I don't agree. There's ample reason to expect a new one when moving towards macros 2.0. RFCs are not necessarily closed to be replaced immediately, they are closed to stop following that line of discussion. Future RFCs might refer to it. |
This comment has been minimized.
This comment has been minimized.
|
I'm with @durka on this. |
dtolnay
referenced this issue
May 3, 2018
Open
Prototype using mashup to eliminate redundant macro inputs #614
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@durka Hygiene opt-out/escaping landing, I mean. |
This comment has been minimized.
This comment has been minimized.
|
OK, that's a lot more uses than I thought! I guess it's hard to replace
them all with mashup because you'd have to generate so many macros?
…On Thu, May 3, 2018, 09:12 Alexander Regueiro ***@***.***> wrote:
@duroa Hygiene opt-out/escaping landing, I mean.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#29599 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAC3n3SwnrGXRRIvhOjPm6wStlrGBXBOks5tuwJWgaJpZM4GcPel>
.
|
This comment has been minimized.
This comment has been minimized.
|
@durka Yeah. I feel |
This comment has been minimized.
This comment has been minimized.
|
@petrochenkov currently |
This comment has been minimized.
This comment has been minimized.
That's a bug.
All identifiers have hygiene with macros >= 1.2!
|
This comment has been minimized.
This comment has been minimized.
|
What should happen with concat_idents!($a, $b) when $a and $b come from
different hygiene contexts?
…On Thu, May 3, 2018 at 1:55 PM, Vadim Petrochenkov ***@***.*** > wrote:
@dtolnay <https://github.com/dtolnay>
currently concat_idents cannot refer to a captured local variable
That's a bug.
and items do not have hygiene.
All identifiers have hygiene with macros >= 1.2!
concat_idents looks like a typical use case for Span::call_site hygiene.
Do you think concat_idents is different enough from other cases of
non-atomic code fragments that we need to block stabilization until the
non-atomic hygiene story is worked out?
concat_idents is not special, #50122
<#50122> (or rather its minimal
subset about call-site for macro invocations) is a blocker for it the same
degree as for Macros 1.2 in general.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#29599 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAC3n8i0Von0gNWwefFkN6Z9NQOoOqFeks5tu0SUgaJpZM4GcPel>
.
|
This comment has been minimized.
This comment has been minimized.
|
@durka |
This comment has been minimized.
This comment has been minimized.
|
@durka I'd expect the same as @petrochenkov. The identifier would then take the syntax context of its call site (i.e. where it's used in code), unless escaped (e.g. using |
This comment has been minimized.
This comment has been minimized.
|
OK, that makes sense. I just remember that being a question that came up
around this macro before.
…On Thu, May 3, 2018 at 2:23 PM, Alexander Regueiro ***@***.*** > wrote:
@durka <https://github.com/durka> I'd expect the same as @petrochenkov
<https://github.com/petrochenkov>. The identifier would then take the
syntax context of its call site (i.e. where it's used in code), unless
escaped (e.g. using # syntax). We have discussed the #[escapes(...)]
approach to escaping hygiene as well, but unless we allow macro expansion
within escapes(...), this becomes a real problem.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#29599 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAC3n0lFw5QraOUxg9z5wJVGp2ANhu8Cks5tu0sigaJpZM4GcPel>
.
|
This comment has been minimized.
This comment has been minimized.
|
@concern premature I don't think we should stabilise concat_idents, between the macro system and the macro itself, this is not the macro that most macro authors want, but it is occupying prime naming real estate. I would prefer to wait until we have a macro that does do what people want before stabilising something. Is there a strong reason to stabilise this now when we've been OK without stabilising it for years? It does seem like a really sub-optimal thing to stabilise. |
This comment has been minimized.
This comment has been minimized.
|
@nrc It does what it says on the tin though, as has been pointed out. Shouldn't the aim just be to work on early (eager) expansion now? |
This comment has been minimized.
This comment has been minimized.
|
So the main issue with "it doesn't do what macro authors want" is that it
only works in expressions, right? It doesn't work for defining things
because macros aren't accepted in ident position. Some possible mitigations:
1. Just make that extremely clear in the documentation
2. Change the name somehow to reflect it (concat_idents_for_expr?
make_expr_name?). If eager expansion actually happens the name would be
awkward, but we could deprecate and change the name back in that case.
3. Make the error message better when discovering a macro invocation in
ident position (currently it's just unexpected `!` with no notes or helps)
…On Sun, May 6, 2018 at 12:14 PM, Alexander Regueiro < ***@***.***> wrote:
@nrc <https://github.com/nrc> It does what it says on the tin though, as
has been pointed out. Shouldn't the aim just be to work on early (eager)
expansion now?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#29599 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAC3n4JGRm5swlmIdV-0ryEkiAjWQU1yks5tvyFKgaJpZM4GcPel>
.
|
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
|
I continue to believe this macro in its current form serves as a valuable building block for API design despite being limited to solving a specific set of use cases and not them all. There comes a time in an experienced macro author's life when they have seen many dozen situations that require exactly this functionality and wonder what the holdup could be after almost 7 years. But I can see that changing so many minds is not going to be a good use of two teams' time. Thanks for the discussion everyone! @rfcbot fcp cancel |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
May 8, 2018
|
@dtolnay proposal cancelled. |
rfcbot
removed
proposed-final-comment-period
disposition-merge
labels
May 8, 2018
This comment has been minimized.
This comment has been minimized.
|
@dtolnay Sounds fair. Maybe we can visit this when hygiene escape support and eager expansion land, both of which I'm currently working on. |
aturon commentedNov 5, 2015
Tracks stabilization for the
concat_identsmacro.