-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Unlock Existential Types for All Protocols #1176
Merged
jckarter
merged 54 commits into
swiftlang:main
from
filip-sakel:NNNN-unlock-existential-types-for-all-protocols
Apr 13, 2021
+319
−0
Merged
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
a4a5adf
Added Draft.
filip-sakel a91f478
Review Updates
filip-sakel 445c7f3
Review Updates.
filip-sakel 40b05a8
Review Updates.
filip-sakel 323a25a
Removed first example from Detailed Design.
filip-sakel a0057fe
Changes per review.
filip-sakel b80a579
Clarified current limitations in Motivation.
filip-sakel d27230f
Updated 'error message'.
filip-sakel 1aa61d1
Updated formatting.
filip-sakel 50a9916
Updated Formatting.
filip-sakel ecbbf4c
Replaced dots(...) with mock types.
filip-sakel 97640d2
Fixed typo and clarified existential qualifiaction
filip-sakel 8f198a8
Updated naming.
filip-sakel 700ec25
Added note for Conflicting Types in Compositions.
filip-sakel 3aa4b1f
Updated formatting.
filip-sakel 86bb68c
Added Existentials in the Standard Library section
filip-sakel d4b9f44
Strengthened motivation by using Strideable.
filip-sakel 65daf57
Rewrote proposal; this is a draft.
filip-sakel 5218234
Added a link to SwiftUI.
filip-sakel 2518bd3
Updated API Resilience.
filip-sakel 1ca02f9
Added API/ABI Resilience Argument
filip-sakel 29c19fd
Removed redundant words / Heterogenous Collections
filip-sakel e8cc29d
Removed unnecessary list of supported existentials
filip-sakel c919e8c
Removed unnecessary list of supported existentials
filip-sakel 8e53926
Removed unnecessary connector in Motivation.
filip-sakel 6eb13b0
Fixed type pointed out by Dave.
filip-sakel 412dc49
Undo incorrect commit.
filip-sakel 3b819cc
Removed unneeded Heterogenous Collections info.
filip-sakel be0d18d
Replaced "synthesized" with "generated".
filip-sakel e151181
Clarified existentials definition in Introduction.
filip-sakel bace022
Clarified Introduction section.
filip-sakel 4b58873
A first round of amendments to the motivation
AnthonyLatsis 0588dc1
Rephrase the introduction to clarify our intentions
AnthonyLatsis 24a3ec2
Address review comments
AnthonyLatsis 16e27a9
Rework the proposed solution and most of the motivation
AnthonyLatsis 0e6f003
Reduce the Effects sections
AnthonyLatsis 13bcd2c
Changes in wording and typo corrections.
filip-sakel 93e80ca
Downside of -> Downside to
filip-sakel c6d414e
Update proposals/NNNN-unlock-existential-types-for-all-protocols.md
AnthonyLatsis 7b3db88
Revert to "of existential type".
filip-sakel ffcbed6
Make Motivation more specific.
filip-sakel 42e7918
Add the alternative of leaving the language as is.
filip-sakel 3c93a1f
Update NNNN-unlock-existential-types-for-all-protocols.md
AnthonyLatsis 1e584d4
Update NNNN-unlock-existential-types-for-all-protocols.md
AnthonyLatsis 927fec1
Remove Heterogenous Collections section.
filip-sakel 6056aba
Remove section for deemphasizing existentials.
filip-sakel be883bd
Decrease section about simplifying existentials.
filip-sakel 016c458
Update NNNN-unlock-existential-types-for-all-protocols.md
AnthonyLatsis 0ebd95c
Update NNNN-unlock-existential-types-for-all-protocols.md
AnthonyLatsis 7ec8f02
Capitalize "c" in Non-conformable Existentials
filip-sakel d49cc87
Remove "Leave the Language in Its Existing State".
filip-sakel 0534ab0
Revert title alteration.
filip-sakel df75054
Add direction for AnyHashable existential init.
filip-sakel 61f6a8e
Update NNNN-unlock-existential-types-for-all-protocols.md
AnthonyLatsis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Remove section for deemphasizing existentials.
- Loading branch information
commit 6056aba4e2517857746098f1e8e9b2c4f6a160a7
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think that we should add a future direction for opening an existential, and then wrapping it into a type-erasure container? For instance,
init(_ box: Hashable)
could be added toAnyHashable
. I'm not sure, though, if this addition could be briefly stated in an existing section, or if we'd have to create a new one.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a bullet point for "automatically opening existentials when passed as generic arguments" at the bottom. That would allow the generic initializer of
AnyHashable
to accept aHashable
value.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would require some implementation work; at the same time, users will be left unable to initialize standard-library-provided type erasers with their language-provided protocol counterparts. I'm not sure if this feature should be part of the proposal, because I think it could create a major usability issue, due to the lack of a feature that can be easily added to the standard library.
Sorry, if I've missed some aspect of the proposed feature that already enables this behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, the part about "automatically opening existential values" is a future direction (it was also mentioned as such a couple of times in the forums); we are not proposing or implementing it now.
In case this is still relevant — why is that? Self-conformance does allow you to initialize an
AnyProtocol
wrapper with aProtocol
value, among other stuff.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't very clear.
I'm arguing that implementing "self-conforming" existential types would require some implementation work, which is — obviously — not in scope for this proposal.
Yet, the current proposal (without self-conformance) creates serious usability issues — provided that I haven't missed anything — since users will be unable to write something like
AnyHashable(1 as Hashable)
.What I propose we do, is include:
Similarly, we could provide such an initializer for
AnyCollection
and any other type-erasing, standard-library wrappers.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. This, then, leaves us just with
AnyHashable
.I understand your concern. I think whether a workaround will be implemented depends on the timing of the follow-up proposal for automatically opening existentials.
How about the following for a future direction bullet:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds fine, but
this would break the ABI (we cannot remove something
public
once added).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I meant "deprecated". Then, after a major version of being deprecated, it could be removed — if that's an option. That, of course, entails that
init(_ box: Hashable)
be marked@_disfavoredOverload
, in addition to deprecated.Is this okay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just changed
if/when ... becomes available
toshould ... become available
.