Giter VIP home page Giter VIP logo

Comments (3)

dtolnay avatar dtolnay commented on September 26, 2024

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.

nrc avatar nrc commented on September 26, 2024

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.

dtolnay avatar dtolnay commented on September 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.