[swift-evolution] [Pitch] merge types and protocols back together with type<Type, Protocol, ...>
Sean Heber
sean at fifthace.com
Mon May 23 15:35:53 CDT 2016
Bikeshedding: Is it grammatically possible (or even desirable) to skip the “any” token and just have something like this:
var view: <UIView, SomeProtocol>
init(view: <UIView, SomeProtocol>) {}
if let mergedValue = button as? <UIView, SomeProtocol> {}
let a: <UIScrollView, <UITableView, any<UIView, ProtocolA>>>
I’m not even sure there’s a huge advantage to leaving it out (avoid capturing a new keyword?) - just thought I’d ask!
And while I’m here asking about (likely very silly) things, I wanted to note that the < and > symbols are heavily ingrained as generics to me and this seems like.. not really the same kind of thing? Has the potential for confusion about this been considered at all? It’s almost like what is being expressed is, “here’s a set/collection of requirements” and, in that case, it almost seems like it should look more like an array:
var view: [UIView, SomeProtocol]
init(view: [UIView, SomeProtocol]) {}
if let mergedValue = button as? [UIView, SomeProtocol] {}
let a: [UIScrollView, [UITableView, [UIView, ProtocolA]]]
Would that lead to a better syntax if such things as generic protocols were possible (assuming they are even desirable)? Example:
let a: [UIView, MyProtocol<Int>]
l8r
Sean - who might just be confused about things due to a lack of attention spa... ooh shiny things!
> On May 23, 2016, at 3:15 PM, Adrian Zubarev via swift-evolution <swift-evolution at swift.org> wrote:
>
> Fixed a few things: https://github.com/DevAndArtist/swift-evolution/blob/classes_in_any_existential/proposals/nnnn-classes-in-any-existential.md
>
> Tell me if I left out any topic or detail.
>
>
>
>
> --
> Adrian Zubarev
> Sent with Airmail
>
> Am 23. Mai 2016 bei 12:08:45, Adrian Zubarev (adrian.zubarev at devandartist.com) schrieb:
>
>> I’ll fix that. I also forgot to change Impact on existing code section. I’ll do that when Austin had time to look at it.
>>
>> This proposal will break protocol A: class {} if we get protocol A: Any<class> {} as replacement.
>>
>>
>>
>> --
>> Adrian Zubarev
>> Sent with Airmail
>>
>> Am 23. Mai 2016 bei 02:52:31, Matthew Johnson (matthew at anandabits.com) schrieb:
>>
>>> Looks pretty good. Just one minor correction.
>>>
>>> Under not valid examples that may be supported in the future you have this:
>>>
>>> extension A where Self == UIView
>>>
>>>
>>> Where you should have this:
>>>
>>> extension A where Self : UIView
>>>
>>> Sent from my iPad
>>>
>>> On May 21, 2016, at 7:42 AM, Adrian Zubarev via swift-evolution <swift-evolution at swift.org> wrote:
>>>
>>>> Proposal was updated as an enhancement proposal to SE–0095. You can read the new draft here:
>>>>
>>>> • https://github.com/DevAndArtist/swift-evolution/blob/classes_in_any_existential/proposals/nnnn-classes-in-any-existential.md
>>>> @Austin: I used some peaces of your enhancement proposal and you’re co-author to this proposal now. If you want to polish something feel free to submit a PR.
>>>>
>>>> • What else do we need in this proposal?
>>>>
>>>>
>>>> --
>>>> Adrian Zubarev
>>>> Sent with Airmail
>>>> _______________________________________________
>>>> swift-evolution mailing list
>>>> swift-evolution at swift.org
>>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
More information about the swift-evolution
mailing list