Skip to content

[DRAFT] Introduce @specialize attribute #2638

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

Merged
merged 7 commits into from
Jan 29, 2025

Conversation

airspeedswift
Copy link
Member

No description provided.

@airspeedswift airspeedswift marked this pull request as draft January 2, 2025 00:46
@airspeedswift airspeedswift changed the title Introduce @specialize attribute [DRAFT] Introduce @specialize attribute Jan 2, 2025
@eeckstein
Copy link
Contributor

@al45tair recently brought up this feature request, which might be good to add in "future directions":

@_specialize only appears to affect functions/methods. That makes sense from an implementation perspective, but it would be nice to be able to write @_specialize on a class or struct to get Swift to specialise all the methods that are affected by the generics on that class or struct without having to write @_specialize before every single one.

@airspeedswift
Copy link
Member Author

airspeedswift commented Jan 2, 2025

it would be nice to be able to write @_specialize on a class or struct

Hmm. There are lots of open questions here. For example, would that get applied to methods added outside the module? I guess it could. That's quite a subtle at-a-distance impact though.

@al45tair
Copy link
Contributor

al45tair commented Jan 3, 2025

Hmm. There are lots of open questions here. For example, would that get applied to methods added outside the module? I guess it could. That's quite a subtle at-a-distance impact though.

That's a great question. I'm not sure whether that's desirable; maybe it should only apply within the defining module, and if someone wants to extend the class and have things specialised they should have to write @_specialize on their extension?

@stephentyrone stephentyrone marked this pull request as ready for review January 29, 2025 14:12
@stephentyrone stephentyrone merged commit c9c4b75 into swiftlang:main Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants