<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><blockquote type="cite" class=""><div class="">On Jun 6, 2016, at 12:02 PM, Rob Norback via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class=""><div class=""><div class=""><div class="">First of all, thank you all for bringing me up to date so quickly.&nbsp; I looked over the proposal and it looks awesome.<br class=""><br class=""></div>But as Chris mentioned, this doesn't solve the expected behavior and ambiguity of ```Array&lt;Int?&gt;```<br class=""></div></div></div></div></div></blockquote><div><br class=""></div><div>I think that name is reserved word on this list :) Just to be clear, I am another Chris (Chris K).</div><div>I forgot to mention that I like the proposal.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><div class=""><div class="">In this case I would expect the default behavior (myArray[4]) without using myArray[checking: 4] should return a nil in this case.</div><br class=""></div><div class="">And Chris, I think it would make the most sense to have myArray[0] = nil to be stored if the index is in Range, and for myArray[100] = nil to give a warning of no assignment being made because index is out of range, kind of like an unused variable.&nbsp; Right now myArray[100] = nil gives you EXC_BAD_INSTRUCTION.&nbsp; Then if you assigned myArray[100] = 200, that would have to simply change the Range.<br class=""></div></div></div></div></blockquote><div><br class=""></div><div>Yes, Arrays should store the value and I do not believe that the syntax for allays would be ambiguous. I do believe that since this is in the same general territory, the syntax for dictionaries should be improved at the same time, to simplify the story for users… perhaps with another keyword(?)</div><div><br class=""></div><div>```&nbsp;</div><div>var d = Dictionary&lt;Int,Int?&gt;<br class="">...<br class="">d[setting:0] = nil<span class="Apple-tab-span" style="white-space: pre;">        </span><span class="Apple-tab-span" style="white-space: pre;">        </span>// I did not give much thought to the name of the keyword.<br class=""></div>```</div><div>A solution that uses the same new syntax should probably be in the same proposal. A separate proposal might be more appropriate for a different solution. &nbsp;</div><div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><div class=""><br class=""></div><div class="">Chris, I honestly have to think more about that ambiguity with dictionaries.<br class=""></div><div class=""><br class=""></div><div class="">I can see that this would definitely need some further fleshing out, but it seems to be sufficiently different from Luis' proposal to perhaps merit it's own proposal.<br class=""></div><div class=""><br class=""></div>It's up to you Luis, but I think this might be a bit more controversial then the changes you've proposed, making it possible for your proposal getting rejected.&nbsp; (I want your proposal accepted, since I would use those features today).&nbsp; Partial acceptance of a proposal doesn't seem to be a thing. (Once again please correct me if I'm wrong).<br class=""></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Mon, Jun 6, 2016 at 11:46 AM Luis Henrique B. Sousa &lt;<a href="mailto:lshsousa@gmail.com" class="">lshsousa@gmail.com</a>&gt; wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">Thanks Vladimir,<div class=""><br class=""></div><div class="">The correct link is this one (with the additional min/max operations in the implementation):&nbsp;</div><div class=""><a href="https://github.com/luish/swift-evolution/blob/proposal-lenient-collection-subscripts/proposals/nnnn-more-lenient-collections-subscripts.md" target="_blank" class="">https://github.com/luish/swift-evolution/blob/proposal-lenient-collection-subscripts/proposals/nnnn-more-lenient-collections-subscripts.md</a></div><div class=""><br class=""></div><div class="">Here is the pull request on the swift-evolution repo:&nbsp;<a href="https://github.com/apple/swift-evolution/pull/328" target="_blank" class="">https://github.com/apple/swift-evolution/pull/328</a></div><div class=""><br class=""></div><div class="">Any help or suggestion to improve the proposal is welcome. :-)</div><div class=""><br class=""></div><div class="gmail_extra"></div></div><div dir="ltr" class=""><div class="gmail_extra"><div class=""><div data-smartmail="gmail_signature" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div style="font-size:small" class="">- Luis</div></div></div></div></div></div></div></div></div></div></div></div></div><div dir="ltr" class=""><div class="gmail_extra">
<br class=""><div class="gmail_quote">On Mon, Jun 6, 2016 at 6:10 PM, Vladimir.S via swift-evolution <span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Please find this draft of proposal(hope this is correct link for latest version):<br class="">
<a href="https://github.com/luish/swift-evolution/blob/more-lenient-subscripts/proposals/nnnn-more-lenient-collections-subscripts.md" rel="noreferrer" target="_blank" class="">https://github.com/luish/swift-evolution/blob/more-lenient-subscripts/proposals/nnnn-more-lenient-collections-subscripts.md</a><br class="">
<br class="">
The main idea is to introduce 2 new subscript methods:&nbsp; [clamping:] and [checking:]<br class="">
<br class="">
There was discussion in "[Proposal] More lenient subscript methods over Collections" and (older) "[Proposal] Safer half-open range operator"<div class=""><div class=""><br class="">
<br class="">
On 06.06.2016 19:50, Rob Norback via swift-evolution wrote:<br class="">
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class=""><div class="">
Hi Everyone!<br class="">
<br class="">
This is my first time emailing the swift evolution list, so if this topic<br class="">
has already been discussed please let me know.&nbsp; I looked through all the<br class="">
accepted and rejected proposals and it doesn't seem to be on there.<br class="">
<br class="">
The main thought is that dictionaries return optionals, so why not arrays?<br class="">
Or other CollectionTypes for that matter.&nbsp; I would think this would be the<br class="">
expected behavior in this situation:<br class="">
<br class="">
var myArray:[String?] = []<br class="">
print(myArray[4])<br class="">
// EXC_BAD_INSTRUCTION, but could just be Optional(nil)<br class="">
<br class="">
Then you could do things like<br class="">
<br class="">
if let arrayValue = myArray[4] {<br class="">
&nbsp; &nbsp;// do something<br class="">
}<br class="">
<br class="">
Of course you could simply check with with the count, but considering<br class="">
Swift's use of optionals to represent empty variables rather than erroring<br class="">
out or returning an empty String, I think this functionality would be<br class="">
appropriate to include in the Swift standard library.<br class="">
<br class="">
And there's about 15,000 people who've looked for this functionality in the<br class="">
last year:<br class="">
<a href="http://stackoverflow.com/questions/25329186/safe-bounds-checked-array-lookup-in-swift-through-optional-bindings" rel="noreferrer" target="_blank" class="">http://stackoverflow.com/questions/25329186/safe-bounds-checked-array-lookup-in-swift-through-optional-bindings</a>.<br class="">
<br class="">
Please let me know what you think.<br class="">
<br class="">
Best,<br class="">
Rob Norback<br class="">
<br class="">
<br class=""></div></div>
_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class="">
</blockquote>
_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
</blockquote></div><br class=""></div></div></blockquote></div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>