Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upExpand docs on Macros By Example. #511
Conversation
This comment has been minimized.
This comment has been minimized.
petrochenkov
reviewed
Jan 15, 2019
src/macros-by-example.md Outdated
petrochenkov
reviewed
Jan 15, 2019
src/macros-by-example.md Outdated
petrochenkov
reviewed
Jan 15, 2019
src/macros-by-example.md Outdated
petrochenkov
reviewed
Jan 15, 2019
src/macros-by-example.md Outdated
petrochenkov
reviewed
Jan 15, 2019
src/macros-by-example.md Outdated
petrochenkov
reviewed
Jan 15, 2019
src/macros-by-example.md Outdated
petrochenkov
reviewed
Jan 15, 2019
src/macros-by-example.md Outdated
petrochenkov
reviewed
Jan 15, 2019
src/macros-by-example.md Outdated
This comment has been minimized.
This comment has been minimized.
|
Reviewed. |
This comment has been minimized.
This comment has been minimized.
|
Not sure what they are up to these days, but @paulstansifer was the original author of the algorithm we use and I don't think the approach has changed much. There is at least some chance they have the time to review this PR =) |
ehuss
reviewed
Jan 15, 2019
|
This is great, I have been looking forward to seeing this! Just yesterday I got a weird "import resolution is stuck, try simplifying macro imports" error, and I think this makes it clearer for me! I've been wondering if it would be useful to make it clear somewhere that |
src/macros-by-example.md Outdated
src/macros-by-example.md Outdated
src/macros-by-example.md Outdated
src/macro-ambiguity.md Outdated
This comment has been minimized.
This comment has been minimized.
|
It looks like the macro guru @petrochenkov has already reviewed, so my input probably isn't needed -- but in brief, good work. :-) |
alercah
force-pushed the
alercah:macro-names
branch
2 times, most recently
from
0573e53
to
def43e0
Jan 19, 2019
estebank
approved these changes
Jan 20, 2019
alercah
force-pushed the
alercah:macro-names
branch
from
def43e0
to
a145d8e
Jan 27, 2019
petrochenkov
reviewed
Jan 27, 2019
| correct because in order for M to accept ε in the complex NT case, both the | ||
| complex NT and α must accept it. If OP = `+`, meaning that the complex NT | ||
| cannot be empty, then by definition ε ∉ ALPHA\_SET(M). Otherwise, the complex NT | ||
| can accept zero repititions, and then ALPHA\_SET(M) = FOLLOW(`α`). So this |
This comment has been minimized.
This comment has been minimized.
petrochenkov
Jan 27, 2019
Contributor
Typo: repititions -> repetitions here and in few other places below.
petrochenkov
reviewed
Jan 27, 2019
| Second, it can be used to import macros from another crate, by attaching it to | ||
| an `extern crate` declaration appearing in the crate's root module. Macros | ||
| imported this way are imported into the prelude of the crate, not textually, | ||
| which means that they can be uare shadowed by any other name. While macros |
This comment has been minimized.
This comment has been minimized.
petrochenkov
approved these changes
Jan 27, 2019
Centril
reviewed
Jan 28, 2019
|
Mostly proofreading... |
src/macro-ambiguity.md Outdated
src/macro-ambiguity.md Outdated
src/macro-ambiguity.md Outdated
src/macro-ambiguity.md Outdated
src/macro-ambiguity.md Outdated
src/macros-by-example.md Outdated
src/macros-by-example.md Outdated
src/macros-by-example.md Outdated
| // m!(); // Error: m is not in scope. | ||
| ``` | ||
|
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Can you add something along these lines?
This explains the difference between: // compiles OK
macro_rules! foo {
($l:tt) => { bar!($l); }
}
macro_rules! bar {
(3) => {}
}
fn main() {
foo!(3);
}macro_rules! foo {
($l:expr) => { bar!($l); }
// ERROR: ^^ no rules expected this token in macro call
}
macro_rules! bar {
(3) => {}
}
fn main() {
foo!(3);
} |
alercah commentedJan 15, 2019
The primary motivation here was to increase clarity and fully address the
scoping and naming details. The inclusion of RFC 550's formal specification is
to move it to the reference where it can be updated. I made several changes,
motivated by accommodating
?and new fragment specifiers, but there are someother things which need highlighting so that they can be double-checked for
correctness.
technical oversight in the definition I believe.
oversight in the original RFC and currently planned for fix.
?repetitionsalready.
The scoping text is probably not completely accurate, but it's certainly much
better than what was there before (i.e. basically nothing).