-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Allow value generics within the stdlib #83710
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
base: main
Are you sure you want to change the base?
Conversation
Value Generics require support from libswiftCore, but that means it is always okay to use value generics within libswiftCore itself, since the runtime support is necessarily present.
@tshortli I'd appreciate if you could double-check my reasoning here. |
The reasoning is not totally sound because making this change means that someone working on the stdlib could introduce a new API that leverages ValueGenerics and the compiler will no longer check whether the public facing availability of the API is correct. I suspect that we ought do something more nuanced that doesn't completely sacrifice the checking that I described above. One option would be to only relax this check when "strict availability checking" is disabled in the build configuration (which is what controls whether |
The other observation about this that I have is that ValueGenerics are not special; any language feature that requires runtime support should probably have the same availability checking relaxation applied to it for the same reasons. I think we ideally ought to refactor things so that there is a funnel point for all runtime feature checks that behaves consistently. I wouldn't blame you if you thought that aspect should be handled by someone else in follow up, though. |
I did some experiments and found out that a slight refinement seems like it would meet both of our needs: This now ignores only non-public stdlib types. I believe this answers your concern: Public stdlib types are still unconditionally checked. I think this can also provide an answer to my concern in #82750: I'm going to experiment with having a separate |
@Azoy @glessard @lorentey -- This would make it possible to add an |
Can't we change the availability of |
@Azoy Not without some work. One problem is that We could change the compiler enforcement to use the equivalent of The core problem I'm trying to resolve for #82750 is that |
I don't think using This is a serious problem for our long-term goal of reimplementing core stdlib and runtime capabilities in Swift rather than C/C++. The C/C++ versions have no availability check overhead, and to achieve performance parity for new Swift versions, we need to be able to similarly guarantee no runtime availability checking for these. We want that parity to be apparent and testable in a variety of environments, and @al45tair should be able to check my reasoning here. If I'm right, then the only really practical approach here is to have duplicate interfaces for core services like InlineArray, Span, etc: One internal version that is not availability-limited for use within the stdlib itself, and another public version that is availability-limited to ensure correct usage by clients. This PR enables that approach. |
It will do, but only if the |
Value Generics require support from libswiftCore, but that means it is always okay to use value generics within libswiftCore itself, since the runtime support is necessarily present.