A Practical Intro to Macros in Rust
11–20 of 26 posts
Re: A Practical Intro to Macros in Rust
#12The concept of a "token tree" as a separate stage between ordinary tokenization and full parsing seems interesting on its own: was it based on another system or invented for Rust? For example, you could imagine implementing incremental parsing by writing your parser as a transformation on a token tree.
Re: A Practical Intro to Macros in Rust
#13The concept of a "token tree" as a separate stage between ordinary tokenization and full parsing seems interesting on its own: was it based on another system or invented for Rust? For example, you could imagine implementing incremental parsing by writing your parser as a transformation on a token tree.
Isn't it how Lisp macros work?
Re: A Practical Intro to Macros in Rust
#14The concept of a "token tree" as a separate stage between ordinary tokenization and full parsing seems interesting on its own: was it based on another system or invented for Rust? For example, you could imagine implementing incremental parsing by writing your parser as a transformation on a token tree.
Isn't it how Lisp macros work?
Re: A Practical Intro to Macros in Rust
#15Note that this dates back to Rust 1.0, and although the macro system hasn't changed since then, plans are in the works to succeed this original system ("macros 1.0") with an improved one ("macros 2.0"), culminating in the deprecation of the original. The two systems won't differ that much, so the documentation will remain mostly the same and the transition should be very straightforward. The impetus for this is that…
Do you have any pointers where this work happens and I can follow along. Searching the RFC's for 'macro' turns up too much noise. Do you know about a timeline?
Re: A Practical Intro to Macros in Rust
#16Note that this dates back to Rust 1.0, and although the macro system hasn't changed since then, plans are in the works to succeed this original system ("macros 1.0") with an improved one ("macros 2.0"), culminating in the deprecation of the original. The two systems won't differ that much, so the documentation will remain mostly the same and the transition should be very straightforward. The impetus for this is that…
> plans are in the works to succeed this original system ("macros 1.0") with an improved one ("macros 2.0") Do you have any pointers where this work happens and I can follow along. Searching the RFC's for 'macro' turns up too much noise. Do you know about a timeline?
For example, one can see that "Macro use and rexport" (https://github.com/rust-lang/rust/issues/35896) that will make macros a part of normal Rust naming and modules is planned for Rust 1.20 to be released end of August.
Re: A Practical Intro to Macros in Rust
#17Earlier quoted context omitted.
> plans are in the works to succeed this original system ("macros 1.0") with an improved one ("macros 2.0") Do you have any pointers where this work happens and I can follow along. Searching the RFC's for 'macro' turns up too much noise. Do you know about a timeline?
While not directly what you are looking for, the release milestone predictions for rust is a fairly nice page IMHO to see current plans: https://internals.rust-lang.org/t/rust-release-milestone-pre... For example, one can see that "Macro use and rexport" ( https://github.com/rust-lang/rust/issues/35896 ) that will make macros a part of normal Rust naming and modules is planned for Rust 1.20 to be released end of Augu…
Re: A Practical Intro to Macros in Rust
#18Earlier quoted context omitted.
While not directly what you are looking for, the release milestone predictions for rust is a fairly nice page IMHO to see current plans: https://internals.rust-lang.org/t/rust-release-milestone-pre... For example, one can see that "Macro use and rexport" ( https://github.com/rust-lang/rust/issues/35896 ) that will make macros a part of normal Rust naming and modules is planned for Rust 1.20 to be released end of Augu…
Actually I think that prediction is now inaccurate, as they in your link "Macro use and rexport" say that they want to postpone the macro changes until Macros 2.0 are ready as a whole.
It is actually one feature I'm quite looking forward to, since I think proper naming for macros will make the whole eco-system simpler. Ah well, now we'll have to wait even longer.
Re: A Practical Intro to Macros in Rust
#19Note that this dates back to Rust 1.0, and although the macro system hasn't changed since then, plans are in the works to succeed this original system ("macros 1.0") with an improved one ("macros 2.0"), culminating in the deprecation of the original. The two systems won't differ that much, so the documentation will remain mostly the same and the transition should be very straightforward. The impetus for this is that…
https://github.com/rust-lang/rust/issues/39412
> Eventually, I hope we can remove macro_rules!. That will take a long time, and would require a 2.0 version of Rust to strictly adhere to our stability guarantees.
Re: A Practical Intro to Macros in Rust
#20Note that this dates back to Rust 1.0, and although the macro system hasn't changed since then, plans are in the works to succeed this original system ("macros 1.0") with an improved one ("macros 2.0"), culminating in the deprecation of the original. The two systems won't differ that much, so the documentation will remain mostly the same and the transition should be very straightforward. The impetus for this is that…
Unfortunate, because metaprogramming is very important to code design. I won't want to abandon code just because v2.0 will get deprecated and shiny v3.0 will become the new standard next year. If Rust team cared about backward compatibility they could preserve old code by adding something like -std=rust1.0 which would not break code. Forcing people to rewrite any code(esp. complex macros) will not gain Rust any goodw…