[swift-evolution] [Pitch] Introduce user-defined dynamically "callable" types
Slava Pestov
spestov at apple.com
Tue Nov 14 00:44:40 CST 2017
> On Nov 13, 2017, at 10:27 PM, Chris Lattner via swift-evolution <swift-evolution at swift.org> wrote:
>
>
>
>> On Nov 13, 2017, at 1:45 AM, Adrian Zubarev <adrian.zubarev at devandartist.com <mailto:adrian.zubarev at devandartist.com>> wrote:
>>
>> Hello Chris, I have some questions about this passage:
>>
>> Before this proposal, the Swift language has two types that participate in call syntax: functions and metatypes (for initialization). Neither of those may conform to protocols at the moment, so this introduces no possible ambiguity into the language.
>> Can you shortly describe why it would be ambiguous if metatypes would conform to protocols?
>>
> It would only be ambiguous if a metatype conformed to the DynamicCallable protocol specifically. This can’t happen today, and if it happened, we could easily define disambiguation rules.
FWIW it looks like we don’t allow calling a value of metatype type as of Swift 3 — you have to add ‘.init’:
t.swift:6:4: error: initializing from a metatype value must reference 'init' explicitly
m()
^
.init
Slava
>
> -Chris
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171113/f4a12a4f/attachment.html>
More information about the swift-evolution
mailing list