-
Notifications
You must be signed in to change notification settings - Fork 214
Macros API stability across language versions #3479
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
Comments
I am currently of the opinion that simply exporting a single version of the APIs through a versioned package (with only one library in it), is all we need here. That package will only have a breaking change on SDK releases that have breaking changes in the macro APIs, which I expect to be rare. |
Thanks! I guess the suggestion is to review once the APIs are substantially complete to check if anything seems like it could be made more robust against changes, e.g. by adding "unknown" to some enum. |
@jakemac53 We need to consider the version constraints on those packages too, and how creating a new SDK or macro API package release affects the ecosystem. Assume we have a
What you write sounds like it's the first choice, but they can all work. In either case, a client of this package then has a dependency of We keep this up for a while, releasing Then we need to do a breaking change to the macro API for SDK 3.10. For some reason, that we can't predict. If we can release a Then, best case, But if just one macro package author is on vacation, and doesn't update their package for a tenday, nobody who depends on that macro package, directly or indirectly, can compile their programs on SDK 3.10. That failure mode is not viable. We must not end in that situation for anything less than a major SDK release. Even if we can keep using the previous major version of This is where it might be reasonable to release the new API as Which kinds of breaking macro API changes are we expecting at all? |
Correct, I think the first choice is the right option. It is the lowest maintenance burden and simplest model, and I believe that dev/beta release periods are sufficient to shake out any dependency upgrades that need to happen such that when a new stable drops, most users can in fact use it. In the cases where a macro dependency hasn't yet upgraded, you can always try a dependency_override as well.
I do not agree that this is a requirement. If you look at the flutter SDK, they already violate this principle through their package pinning. Yes, it makes it painful to do a breaking change in any of those packages that are pinned, but it ultimately is possible to do still. In fact, it is all but guaranteed that flutter will pin package:macros anyways (assuming they ship some macros, but I think that is quite likely), so it will already be forced to exactly one version for each SDK, regardless of what we do, for the vast majority of our users.
For any macro with a sufficient number of users, this should come up way before any stable release. We could even maintain a list of popular macro packages and pro-actively file issues on them if/when a breaking change is coming. This is a pretty common tactic actually, you just keep a text file with a list of package names in the repo, and people can file a PR to add their package to the list.
It is worth mentioning that they can use dependency overrides, and this might be enough (if all that is needed is a version constraint change in that package). But yes, in this situation a user may be blocked from upgrading their SDK to the latest version.
The primary issue with this is it would be a potentially very large maintenance burden for us. All supported versions of the APIs would have to exist side by side in the SDK, and at a minimum the CFE/Analyzer would have to support all of those versions explicitly. It is imo too much complexity to take on compared to the size of the problem it fixes, at least under the assumption that breaking API changes are quite rare anyways.
I honestly can't think of any case in the past that would have required one. Even null safety probably would not have necessitated a breaking change. And even if we removed something from the language (lets say, we removed classes), the API for classes would remain because macros could still be running against older language versions. We would essentially have to fundamentally change the structure of some declaration in the language in such a way that the API for introspecting on that declaration had to be changed in order to support it. As an example, if we gave functions multiple return values/types. The API surface area is nearly identical to that of
We have a The There are no visitor interfaces, my thought on that is if people want them it should be fairly trivial to implement those as a separate package on top of the existing APIs.
Yes, the package will almost certainly be just a re-export of a private SDK library so they will be directly correlated, if I understand your question correctly. We would probably do explicit exports of certain symbols to ensure we don't accidentally leak any API we didn't mean to, which could allow us some time to be working on an addition to the API without directly exposing it to users. |
The package manager for Go does this implicitly. Major versions of the same package are considered different package names, and an application can have multiple major versions of the same package in the. Go's structural typing makes that much more tenable, but I do wonder sometimes if a similar approach would be a good idea for Dart. |
Closing in favour of #3706 |
Forked from discussion in #3466, the topic is how to avoid breaking changes to the macros API when there are language changes.
If the macros API can always avoid major version increases then macros will continue working "for free" on new SDK releases.
#3466 (comment)
The text was updated successfully, but these errors were encountered: