Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simple postfix macros #2442
base: master
Are you sure you want to change the base?
Simple postfix macros #2442
Changes from 10 commits
684fae5
86c29a3
bdf9e41
e35414c
423237e
b4544df
b0605db
221de8e
0ebe83e
24999bb
dac0943
cd18fc9
81e1e8d
be68f24
f32688f
c9cb3be
fcf7a57
68d7673
3e99287
f2d4bd0
07c26b6
21cd66c
4467a5e
e0cb6bc
d966d41
293e8d6
df0b8f7
82da7f9
446b802
32ba75f
5711eca
c13ba49
731dbc6
a409770
37b333d
0194091
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just adding a new matcher
self
would probably be enough -$anything: self
.During matching it wouldn't match anything except for a "method receiver" in
expr.my_macro!(...)
, but during expansion it would work asexpr
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚲 🏠: I think in order to be consistent with function syntax it should be
$self
as in($self, $msg:expr) => ({
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@petrochenkov That's exactly what I intended. I described the
:self
as a new "designator", because the Rust documentation used that term. Do you mean something different when you describe it as a "matcher"?@est31 I considered that possibility; however, in addition to the inconsistency of not using a descriptor, that would limit potential future expansion a bit. Today, you can write
$self:expr
and use$self
, without the compiler attaching any special meaning to the use of the nameself
as a macro argument. So, making$self
without a descriptor special seems inconsistent in a problematic way.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joshtriplett
I see, the RFC never shows an example with
$not_self: self
, so I thought that$self
is mandatory.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@petrochenkov Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joshtriplett good point. Ultimately I don't care much about the actual syntax.