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

Not clear sentence "Eager expansion generally performs a subset of the things that lazy (normal) expansion does." #1871

Open
Arthur-Milchior opened this issue Jan 28, 2024 · 0 comments
Labels
A-macros Area: macros (general sense) E-hard Difficulty: might require advanced knowledge I-confusing Issue: info is confusing to readers T-compiler Relevant to compiler team

Comments

@Arthur-Milchior
Copy link
Contributor

In https://rustc-dev-guide.rust-lang.org/macro-expansion.html I fear the sentence

Eager expansion generally performs a subset of the things that lazy (normal) expansion does.

is not clear. And I'd suggest, maybe, to give an example in order to clarify it.

I could imagine that you mean that, in the following example

macro bar($i: ident) { $i }
macro foo($i: ident) { $i + $i }

foo!(bar!(5))

an eager expansion would lead to a single expansion of bar while the normal expansion will lead to two expansions of bar .
However, the query system that was described in the previous section seems to indicate that the expansion would consist in a single query call with a cached result, so that would be very cheap.

Also, if we consider

macro bar($i: ident) { $i }
macro foo($i: ident) {  }

foo!(bar!(5))

an eager expansion would lead to expending bar, while a normal expansion would avoid this expansion; showing that there are also case where the eager expansion do more work.

My best hypothesis, to be honest, right now, is that the sentence should be read with eager and lazy reversed

@jieyouxu jieyouxu added T-compiler Relevant to compiler team A-macros Area: macros (general sense) I-confusing Issue: info is confusing to readers E-hard Difficulty: might require advanced knowledge labels Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: macros (general sense) E-hard Difficulty: might require advanced knowledge I-confusing Issue: info is confusing to readers T-compiler Relevant to compiler team
Projects
None yet
Development

No branches or pull requests

2 participants