Skip to content

New chapter on procedural macros #155

@japaric

Description

@japaric

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions