<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Dimitri,<div class=""><br class=""></div><div class="">Excuse me if I’m being dumb. I saw those example but I don’t understand their use.</div><div class=""><br class=""></div><div class="">If I define a custom Collection, I still have the be explicit in the types I use where associated types are expected. Because I need to be explicit, I don’t understand how default associated types are used.</div><div class=""><br class=""></div><div class="">Default parameters seem clear to me:</div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">func foobar(a: Int = 0) {}</font></div><div class=""><font face="Menlo" class="">foo() // implicit uses default value</font></div><div class=""><font face="Menlo" class="">foo(a: 1) // Explicit bypasses default value</font></div><div class=""><br class=""></div><div class="">But default associated types are not:</div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">protocol Foobar {</font></div><div class=""><font face="Menlo" class=""> associatedtype Foo = Int</font></div><div class=""><font face="Menlo" class=""> func foobar(a: Foo)</font></div><div class=""><font face="Menlo" class="">}</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">class FoobarImpl : FooBar {</font></div><div class=""><font face="Menlo" class=""> func foobar(a: Foo) {} // error: Use of undeclared type ‘Foo’ - there is no such thing as an implicit use</font></div><div class=""><font face="Menlo" class=""> func foobar(a: Double) {} // This works but is explicit</font></div><div class=""><font face="Menlo" class="">}</font></div><div class=""><br class=""></div><div class="">I just don’t see the implicit use of the default associated type.</div><div class=""><br class=""></div><div class="">David.</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 29 Apr 2016, at 09:36, Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com" class="">gribozavr@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">On Fri, Apr 29, 2016 at 12:25 AM, David Hart via swift-evolution<br class=""><<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><blockquote type="cite" class="">I’ve taken some time to digest the current feedback and I’ve changed my mind. The syntax for adding constraints to a sub-protocol in the protocol’s definition where clause is starting to grow on me. Before I modify the proposal, I'd still like to understand something:<br class=""><br class="">What is the use of declaring a default associated types with the `=` syntax in protocols? I’ve never used them and I don’t understand what they provide.<br class=""></blockquote><br class="">Please take a look at the Collection protocol<br class="">(<a href="https://github.com/apple/swift/blob/master/stdlib/public/core/Collection.swift" class="">https://github.com/apple/swift/blob/master/stdlib/public/core/Collection.swift</a>).<br class=""><br class="">associatedtype Iterator : IteratorProtocol = IndexingIterator<Self><br class="">associatedtype SubSequence : IndexableBase, Sequence = Slice<Self><br class="">associatedtype Indices : IndexableBase, Sequence = DefaultIndices<Self><br class=""><br class="">Some collections want to customize these, but for simple ones the<br class="">defaults are usually fine.<br class=""><br class="">Dmitri<br class=""><br class="">-- <br class="">main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if<br class="">(j){printf("%d\n",i);}}} /*Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com" class="">gribozavr@gmail.com</a>>*/<br class=""></div></div></blockquote></div><br class=""></div></body></html>