-
Notifications
You must be signed in to change notification settings - Fork 2.4k
[Revision] SE-0253: Introduce callables. #1037
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
Conversation
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.
The proposal looks pretty good. In addition to the comments I mentioned above, the proposal should mention that the x.call
syntax can be used to refer to the callable in a partially applied way, and this syntax aligns with the Type.init
syntax.
@@ -3,8 +3,9 @@ | |||
* Proposal: [SE-0253](https://github.com/apple/swift-evolution/blob/master/proposals/0253-callable.md) |
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.
The proposal name is very generic, and Swift already has callable things. How about "User Defined Callable Types"?
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'm intentionally avoiding "callable types" because 1. func call
is not restricted to primary type declarations and there's no type declaration attributes, and 2. types being callable sound like initializers.
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 changed the title to "User-defined callable values". What do you think?
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.
Isn't fp a user defined callable value?
var fp : () -> () = {}
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's a good point. How about "non-function callable values"?
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.
Metatypes.
Why not call this "Allowing user defined types to be callable"?
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.
Metatypes are not callable today actually, though I understand in the implementation they are.
let x = Float.self
x(2)
error: repl.swift:2:2: error: initializing from a metatype value must reference 'init' explicitly
x(2)
^
.init
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 changed it to "Callable values of user-defined nominal types" to be a bit more accurate. Hope that sounds okay to you!
A few other observations:
|
Mentioned in the "detailed design" section.
Done.
Moved to "alternatives considered".
Done. |
Implementation: swiftlang/swift#24299