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

New chapter on procedural macros #155

Closed
japaric opened this issue Jul 3, 2014 · 2 comments
Closed

New chapter on procedural macros #155

japaric opened this issue Jul 3, 2014 · 2 comments

Comments

@japaric
Copy link
Member

japaric commented Jul 3, 2014

Our macro_rules! chapter covers macros by example, which is one flavour of macros.

We need a new chapter that covers procedural macros, which work at the AST level.

For some ideas check the #[quickcheck] attribute used by the quickcheck library, which expands into a test harness and a quickcheck call: #[test] + quickcheck(property). I think this is one of the simplest uses of procedural macros.

For more examples in the wild, the rustc --pretty expanded command can be used to reveal the magic behind the #[deriving(...)] attribute, which is also a procedural macro. This will show the expansion of the macro, but the definiton of these macros can be found under libsyntax/ext/deriving

@japaric japaric added the C-new label Jul 3, 2014
@japaric japaric mentioned this issue Jul 3, 2014
52 tasks
@mitchmindtree
Copy link

+1 would love to see a nice concise example for procedural macros 👍

@steveklabnik
Copy link
Member

Given that procedural macros aren't going to be stable for a long time, while I agree this would be something to add, it isn't really relevant until then. Therefore, I'm giving this a close for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants