Comments (3)
A reason that macros are moving to tokens/strings rather than AST is for the stability of procedural macros. This requires that libraries such as Syn have a forwards compatibility policy.
I don't think that follows. Procedural macros don't declare a dependency on a specific compiler version, but they do declare a dependency on a specific Syn version and Cargo is good at managing those. By choosing a version they choose a snapshot of the Rust syntax to support. This is no different from using Syntex which was sort of the plan for how Macros 1.1 would be used, specifically mentioned in the RFC.
The biggest benefit over Syntex after compile time is that I expect Syn to be easier to maintain by a factor of 10x to 50x. This is from the person who has been maintaining Syntex for the past several months. The current release is out of date by 2 weeks just because the merge conflict is so bad. I do not foresee that happening with Syn because every syntax change will be just a few minutes to implement. That means, in contrast to Syntex, procedural macros will be able to support new syntax almost immediately rather than waiting for potentially weeks.
I agree there is something around pattern matching that could be done in a better way. I will keep thinking about that. Thanks for flagging this!
from syn.
First of all, s/forwards/backwards, sorry about the confusion there.
You are right that Cargo can manage the dependency issues without intervention, and we avoid most of the back-compat nightmare that is current macros simply by not depending on the compiler version.
I guess what I'm talking about is steps you can take to make having to bump a major version number less likely. I.e., it would be nice if adding say struct field defaults only meant going from v3.2 to 3.3 rather than 4.0.
from syn.
I don't have a good answer to this. We will bump a major version when syntax changes require it, as infrequently as reasonable, and count on Cargo to sort out dependencies on syn.
from syn.
Related Issues (20)
- Delete From impls of ast enums HOT 2
- Consider inserting invisible groups, rather than parens, when applying grouping for precedence HOT 1
- Implement `Debug` for the AST nodes HOT 1
- parse_nested_meta don't work on attribute with multiple meta HOT 2
- Struct Literals in ExprLet HOT 1
- Parse `safe` items in extern blocks
- Parse precise capturing syntax HOT 1
- Scope when parsing delimited group content does not necessarily belong to the right Group token
- Parsing function using `parse` referencing enum fails HOT 1
- Parse attributes on where-predicates
- Deny keyword lifetimes pre-expansion
- Parse unsafe attributes
- Parse unnamed C varargs within function pointer types HOT 1
- [Feature Request] Add support for incomplete expression and statement HOT 1
- FieldMutability is missing Parse and ToTokens HOT 1
- Breaking change to `Generics::lifetimes` in v2.0.73 HOT 8
- ExprPath to_tokens() output can't be parsed as an expression due to missing turbofish
- A
- Documentation discrepancy between `parse` and `parse2`
- Generics::split_for_impl can cause clippy::multiple_bound_locations HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from syn.