<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=""><br class=""><div class=""><div><blockquote type="cite" class=""><div class="">On Feb 3, 2017, at 2:58 PM, Ben Cohen <<a href="mailto:ben_cohen@apple.com" class="">ben_cohen@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Feb 3, 2017, at 11:12 AM, Erica Sadun via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">I believe what people *want* is `indexed` over `enumerated`, and consistently for both array and array slices.</div><br class="Apple-interchange-newline"></div></blockquote></div><br class=""><div class="">I don’t know if that’s true.</div><div class=""><br class=""></div><div class="">Here’s an example (the only use of enumerated) from Alamofire:</div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> acceptLanguage = </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">Locale</span><span class="" style="font-variant-ligatures: no-common-ligatures;">.</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">preferredLanguages</span><span class="" style="font-variant-ligatures: no-common-ligatures;">.</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">prefix</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(6).</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">enumerated</span><span class="" style="font-variant-ligatures: no-common-ligatures;">().</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">map</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> { index, languageCode </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">in</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"> </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> quality = 1.0 - (</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">Double</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(index) * 0.1)</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"> </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">return</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(180, 38, 26);">"</span><span class="" style="font-variant-ligatures: no-common-ligatures;">\</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(180, 38, 26);">(</span><span class="" style="font-variant-ligatures: no-common-ligatures;">languageCode</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(180, 38, 26);">);q=</span><span class="" style="font-variant-ligatures: no-common-ligatures;">\</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(180, 38, 26);">(</span><span class="" style="font-variant-ligatures: no-common-ligatures;">quality</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(180, 38, 26);">)"</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">}.</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">joined</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(separator: </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(180, 38, 26);">", "</span><span class="" style="font-variant-ligatures: no-common-ligatures;">)</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"><br class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"></span></div></div><div class="">Here the intent is a counter, not indices. They just happen to be the same. But if they’d used <span class="" style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">indexed</span><span class="" style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;">()</span> it would certainly hurt readability, albeit midly.</div><div class=""><br class=""></div><div class="">Suppose there wasn’t an enumerate or an indexed, and zipped was the standard way of doing it. That might lead to another solution:</div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> qualities = </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">stride</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(from: 1.0, to: 0.4, by: -0.1)</span></div><div class="" style="margin: 0px; line-height: normal; color: rgb(52, 149, 175);"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> acceptLanguage = </span><span class="" style="font-variant-ligatures: no-common-ligatures;">Locale</span><span class="" style="font-variant-ligatures: no-common-ligatures;">.</span><span class="" style="font-variant-ligatures: no-common-ligatures;">preferredLanguages</span><span class="" style="font-variant-ligatures: no-common-ligatures;">.</span><span class="" style="font-variant-ligatures: no-common-ligatures;">zipped</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(with: </span><span class="" style="font-variant-ligatures: no-common-ligatures;">qualities</span><span class="" style="font-variant-ligatures: no-common-ligatures;">).</span><span class="" style="font-variant-ligatures: no-common-ligatures;">map</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> {</span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"> languageCode, quality </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">in</span><span class="" style="font-variant-ligatures: no-common-ligatures;"> </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(180, 38, 26);">"</span><span class="" style="font-variant-ligatures: no-common-ligatures;">\</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(180, 38, 26);">(</span><span class="" style="font-variant-ligatures: no-common-ligatures;">languageCode</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(180, 38, 26);">);q=</span><span class="" style="font-variant-ligatures: no-common-ligatures;">\</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(180, 38, 26);">(</span><span class="" style="font-variant-ligatures: no-common-ligatures;">quality</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(180, 38, 26);">)"</span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;">}.</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">joined</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(separator: </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(180, 38, 26);">", "</span><span class="" style="font-variant-ligatures: no-common-ligatures;">)</span></div><div class="" style="margin: 0px; line-height: normal; min-height: 13px;"><span class="" style="font-variant-ligatures: no-common-ligatures;"></span><br class=""></div></div></div><div class="">The use of stride here feels more what was intended, rather than backing into the quality via an “index” value. And avoids any risk with indexed of this getting applied incorrectly to slices.</div><div class=""><br class=""></div></div></div></blockquote><br class=""></div><div>I think enumerated as it stands is an attractive nuisance / moral hazard. Most of the language learners I interact with miss the point and the nuance of how it works.</div><div><br class=""></div><div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);" class="">let</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> list = [</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">0</span><span style="font-variant-ligatures: no-common-ligatures;" class="">, </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">1</span><span style="font-variant-ligatures: no-common-ligatures;" class="">, </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">2</span><span style="font-variant-ligatures: no-common-ligatures;" class="">, </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">3</span><span style="font-variant-ligatures: no-common-ligatures;" class="">, </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">4</span><span style="font-variant-ligatures: no-common-ligatures;" class="">]</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);" class="">let</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> slice = </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);" class="">list</span><span style="font-variant-ligatures: no-common-ligatures;" class="">[</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">2</span><span style="font-variant-ligatures: no-common-ligatures;" class="">...</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">3</span><span style="font-variant-ligatures: no-common-ligatures;" class="">]</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);" class="">for</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> (idx, value) </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);" class="">in</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);" class="">slice</span><span style="font-variant-ligatures: no-common-ligatures;" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(62, 30, 129);" class="">enumerated</span><span style="font-variant-ligatures: no-common-ligatures;" class="">() {</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(62, 30, 129);" class="">print</span><span style="font-variant-ligatures: no-common-ligatures;" class="">(idx, value)</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">}</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><br class=""></span></div></div><div>I think people would not expect 0, 2 / 1, 3. I also don’t think they’d expect the actual outcome from a dictionary, whether index or enumeration because there’s no inherent semantic “enumeration” of dictionary values:</div><div><br class=""></div><div> </div><div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);" class="">let</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> dict = [</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">0</span><span style="font-variant-ligatures: no-common-ligatures;" class="">:</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(209, 47, 27);" class="">"a"</span><span style="font-variant-ligatures: no-common-ligatures;" class="">, </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">1</span><span style="font-variant-ligatures: no-common-ligatures;" class="">:</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(209, 47, 27);" class="">"b"</span><span style="font-variant-ligatures: no-common-ligatures;" class="">, </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">2</span><span style="font-variant-ligatures: no-common-ligatures;" class="">:</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(209, 47, 27);" class="">"c"</span><span style="font-variant-ligatures: no-common-ligatures;" class="">]</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);" class="">for</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> (idx, value) </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);" class="">in</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);" class="">dict</span><span style="font-variant-ligatures: no-common-ligatures;" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(62, 30, 129);" class="">enumerated</span><span style="font-variant-ligatures: no-common-ligatures;" class="">() {</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(62, 30, 129);" class="">print</span><span style="font-variant-ligatures: no-common-ligatures;" class="">(idx, value)</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">}</span></div></div><div><br class=""></div><div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><b class="">0 (2, "c")</b></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><b class="">1 (0, "a")</b></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><b class="">2 (1, "b")</b></span></div><div class=""><br class=""></div><div class="">I’d like to see enumerated gone and I have a mild preference for introducing indexed, either under its own name or as a new behavior for enumerated (although T where T.Iterator.Element is Int)</div><div class=""><br class=""></div><div class="">120 gists with “enumerated”, of which a casual scan shows that almost none of them are actually using it meaningfully. (Take a look.) I think I did this API right: <a href="https://api.github.com/search/repositories?q=enumerate+language:swift" class="">https://api.github.com/search/repositories?q=enumerate+language:swift</a> and if so, not much in repos.</div><div class=""><br class=""></div></div></div><div class=""><br class=""></div></body></html>