Skip to content
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

The macro chapter needs hygiene :P #683

Merged
merged 22 commits into from
May 8, 2020
Merged

Conversation

mark-i-m
Copy link
Member

@mark-i-m mark-i-m commented Apr 25, 2020

The first commit does some cleanup and resolves #645

I am planning to finally finish turning the discussion on hygiene into a proper section, which resolves #398.

cc #15

EDIT: I think we can consider this to reasonable address #15 too.
closes #15
closes #176

@mark-i-m
Copy link
Member Author

Sitll WIP, but a note to reviewers: the diff for macro-expansion.md is pretty messy. You might just want to read the final version from top to bottom...

@mark-i-m mark-i-m marked this pull request as ready for review May 1, 2020 02:23
@mark-i-m
Copy link
Member Author

mark-i-m commented May 1, 2020

Ok, I'm sure there are a bunch of broken links and things, but I think this is ready for some review, @rust-lang/wg-rustc-dev-guide

Copy link
Member

@chrissimpkins chrissimpkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mark-i-m Tremendous amount of work here. This looks great! I am at the Producing Macro Output section and will get to the rest in the next few days. I figured I would submit what I have right now.

One general comment so far. This is a really lengthy text that goes into great detail. That is good IMO. But I think that a bit of organization would help to guide the reader. I indicated a few areas where section headers might be helpful to separate large text passages. I also suggest moving the lazy vs. eager discussion out of the early part of the text and into a separate linked section at the bottom of the document (or maybe an Appendix?). This dives into a detailed review against an edge case situation and distracts from the message about how default expansion happens.

I think that something like:

"With few exceptions, we use this method on the whole crate (see Lazy vs. Eager Expansion section below for more detailed discussion of edge case expansion issues)"

There are a large number of heirarchy -> hierarchy spelling corrections. I used the GH interface to indicate where they are all located. Please don't accept all of those commits :)

This really looks great Mark. Many thanks for the time and effort that you invested here. I am learning a great deal from this chapter.

### Hygiene
A lazy expansion would expand `foo!` first. An eager expansion would expand
`bar!` first. Implementing eager expansion more generally would be challenging,
but we implement it for a few special built-in macros for the sake of user
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rationale indicated here duplicates a line in the paragraph before the code block, but provides different rationale for why there is min support:

This is implemented only for a few special built-in macros that expect literals (it's not a generally available feature of Rust).

Suggest removal of one of them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that because they only take literals, expanding early produces better UX (but tbh, I don't know how off the top of my head).

I tried to reword to make that a bit clearer.

mark-i-m and others added 4 commits May 2, 2020 20:54
Co-authored-by: Chris Simpkins <git.simpkins@gmail.com>
Co-authored-by: Chris Simpkins <git.simpkins@gmail.com>
@mark-i-m
Copy link
Member Author

mark-i-m commented May 3, 2020

Thanks @chrissimpkins! I like your suggestions on organization. I think that there are a lot of random details jammed into different places, so if you feel they should be moved, that's helpful feedback.

@spastorino
Copy link
Member

Is this one ready to merge?.

@mark-i-m
Copy link
Member Author

mark-i-m commented May 7, 2020

I was under the impression it was still under review?

Copy link
Member

@chrissimpkins chrissimpkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read the rest of your changes here @mark-i-m. One very minor typo edit. LGTM!

Does Vadim know that this is available for review?

@petrochenkov
Copy link
Contributor

I read this a couple of days ago and it looked good.

Co-authored-by: Chris Simpkins <git.simpkins@gmail.com>
@mark-i-m mark-i-m merged commit b6d140f into rust-lang:master May 8, 2020
@mark-i-m mark-i-m deleted the hygiene branch May 8, 2020 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants