<div dir="ltr">Painful +1.<div><br></div><div>I use the first one a whole lot in a project and it is going to get ugly. That said… I can see how it is tricky in a way that doesn't really pay off for most people. Removing the first feature might even be necessary for what I hope will ease the ugly. I don't see "Default generic arguments" being easy to reason about alongside the first feature.</div><div><br></div><div>TJ</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 11, 2016 at 9:30 PM, Robert Widmann via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">+1. I don't use this feature at all and (by extension) don't think there are many situations where it's useful.<br>
<br>
~Robert Widmann<br>
<br>
2016/10/11 18:03、Slava Pestov via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> のメッセージ:<br>
<div class="HOEnZb"><div class="h5"><br>
> I could if there’s interest. Since we intend on maintaining source compatibility, it will not result in a simpler implementation, though, since we’ll need to keep the old code path around for Swift 3 mode. Still worth it?<br>
><br>
> Slava<br>
><br>
>> On Oct 11, 2016, at 1:58 PM, Pyry Jahkola <<a href="mailto:pyry.jahkola@iki.fi">pyry.jahkola@iki.fi</a>> wrote:<br>
>><br>
>> I was reminded of this proposal which seems like an obvious win in clarity. Still planning to submit it, Slava?<br>
>><br>
>> ― Pyry<br>
>><br>
>>> On 28 Jun 2016, at 21:13, Dave Abrahams via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br>
>>><br>
>>> on Thu Jun 23 2016, Slava Pestov <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br>
>>><br>
>>>> Simpler interpretation of a reference to a generic type with no<br>
>>>> arguments<br>
>>>><br>
>>>> Proposal: SE-9999<br>
>>>> <<a href="https://github.com/slavapestov/swift-evolution/blob/silly-proposals/proposals/9999-simplify-unbound-generic-type.md" rel="noreferrer" target="_blank">https://github.com/<wbr>slavapestov/swift-evolution/<wbr>blob/silly-proposals/<wbr>proposals/9999-simplify-<wbr>unbound-generic-type.md</a>><br>
>>>> Author: Slava Pestov <<a href="https://github.com/slavapestov" rel="noreferrer" target="_blank">https://github.com/<wbr>slavapestov</a>><br>
>>>> Status: Awaiting review<br>
>>>> Review manager: TBD<br>
>>>> <<a href="https://github.com/slavapestov/swift-evolution/tree/silly-proposals/proposals#introduction" rel="noreferrer" target="_blank">https://github.com/<wbr>slavapestov/swift-evolution/<wbr>tree/silly-proposals/<wbr>proposals#introduction</a>><wbr>Introduction<br>
>>>><br>
>>>> This proposal cleans up the semantics of a reference to a generic type<br>
>>>> when no generic arguments are applied.<br>
>>>><br>
>>>> Swift-evolution thread: Discussion thread topic for that proposal<br>
>>>> <<a href="http://news.gmane.org/gmane.comp.lang.swift.evolution" rel="noreferrer" target="_blank">http://news.gmane.org/gmane.<wbr>comp.lang.swift.evolution</a>><br>
>>>> <<a href="https://github.com/slavapestov/swift-evolution/tree/silly-proposals/proposals#motivation" rel="noreferrer" target="_blank">https://github.com/<wbr>slavapestov/swift-evolution/<wbr>tree/silly-proposals/<wbr>proposals#motivation</a>><wbr>Motivation<br>
>>>><br>
>>>> Right now, we allow a generic type to be referenced with no generic<br>
>>>> arguments applied in a handful of special cases. The two primary rules<br>
>>>> here are the following:<br>
>>>><br>
>>>> If the scope from which the reference is made is nested inside the<br>
>>>> definition of the type or an extension thereof, omitting generic<br>
>>>> arguments just means to implicitly apply the arguments from context.<br>
>>>><br>
>>>> For example,<br>
>>>><br>
>>>> struct GenericBox<Contents> {<br>
>>>> let contents: Contents<br>
>>>><br>
>>>> // Equivalent to: func clone() -> GenericBox<Contents><br>
>>>> func clone() -> GenericBox {<br>
>>>> return GenericBox(contents: contents)<br>
>>>> }<br>
>>>> }<br>
>>>><br>
>>>> extension GenericBox {<br>
>>>> func print() {<br>
>>>> // Equivalent to: let cloned: GenericBox<Contents><br>
>>>> let cloned: GenericBox = clone()<br>
>>>> print(cloned.contents)<br>
>>>> }<br>
>>>> }<br>
>>>> If the type is referenced from an unrelated scope, we attempt to infer<br>
>>>> the generic parameters.<br>
>>>><br>
>>>> For example,<br>
>>>><br>
>>>> func makeABox() -> GenericBox<Int> {<br>
>>>> // Equivalent to: GenericBox<Int>(contents: 123)<br>
>>>> return GenericBox(contents: 123)<br>
>>>> }<br>
>>>> The problem appears when the user expects the second behavior, but<br>
>>>> instead encounters the first. For example, the following does not type<br>
>>>> check:<br>
>>>><br>
>>>> extension GenericBox {<br>
>>>><br>
>>>> func transform<T>(f: Contents -> T) -> GenericBox<T> {<br>
>>>> // We resolve 'GenericBox' as 'GenericBox<Contents>', rather than<br>
>>>> // inferring the type parameter<br>
>>>> return GenericBox(contents: f(contents))<br>
>>>> }<br>
>>>> }<br>
>>>> <<a href="https://github.com/slavapestov/swift-evolution/tree/silly-proposals/proposals#proposed-solution" rel="noreferrer" target="_blank">https://github.com/<wbr>slavapestov/swift-evolution/<wbr>tree/silly-proposals/<wbr>proposals#proposed-solution</a>><wbr>Proposed<br>
>>>> solution<br>
>>>><br>
>>>> The proposed solution is to remove the first rule altogether. If the<br>
>>>> generic parameters cannot be inferred from context, they must be<br>
>>>> specified explicitly with the usual Type<Args...> syntax.<br>
>>><br>
>>> SGTM. I've always found this shorthand to be somewhat surprising,<br>
>>> including in C++ where (IIUC) it originated.<br>
>>><br>
>>><br>
>>> --<br>
>>> Dave<br>
>><br>
><br>
> ______________________________<wbr>_________________<br>
> swift-evolution mailing list<br>
> <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
</div></div></blockquote></div><br></div>