<div>RangeExpression is a protocol for all ranges, including partial and unbounded ranges. It would not make sense for such a protocol to have an upper bound or a lower bound.<br><br><div dir="auto">The way in which your proposal could dovetail with RangeExpression is for it to add a requirement to that protocol named `clamping(_:)`. Each type of range (_, closed, countable, countable closed, partial from, partial up to, etc.) would then implement that requirement. Then, implementations of `clamped(to:)` could call `clamping(_:)`. Although, at that point, it would be an open question whether having both clamped(to:) and clamping(_:) would be useful. I would be inclined to think that at most one of these is necessary, and only the latter is compatible with a protocol-based approach.</div><br><div dir="auto">I remain unconvinced, however, that this API meets the very high bar for standard library inclusion.</div><br></div><div><br><div class="gmail_quote"><div>On Tue, Jun 27, 2017 at 20:57 Nicholas Maccharoli via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)">Swift Evolution, </div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)"><br></div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)">I want to thank the community for the previous feedback for SE-0177 </div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)">and also address the issue of the proposal being sent back for revisions. </div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)"><br></div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)">The current status being &quot;Returned for revisions&quot; reflects the detailed </div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)">design section being incomplete and not working against the latest Swift 4 </div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)">snapshot. </div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)"><br></div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)">Another reason mentioned by Ben Cohen was that the proposal did not take </div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)">advantage of `RangeExpression` and take advantage of a generic implementation. </div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)"><br></div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)">This has been added in the &quot;Alternatives Considered&quot; section in the pull request that</div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)">is open now but I personally favor the generic approach despite the added cost of extending `RangeExpression` enough to make the implementation possible. </div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)"><br></div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)">In short, at this time `RangeExpression` is lacking functionality to implement `clamp(to:)` </div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)">in a generic fashion so if the community is in favor of extending `RangeExpression` I am </div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)">more than happy to go with a generic implementation rather than the current concrete </div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)">implementation that is in the proposal pull request now.</div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)"><br></div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)">I have tried to address these issues and expand the proposal in this pull request here:</div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)"><br></div><div class="gmail_default"><font color="#274e13" face="comic sans ms, sans-serif"><a href="https://github.com/apple/swift-evolution/pull/723" target="_blank">https://github.com/apple/swift-evolution/pull/723</a></font><br></div><div class="gmail_default"><font color="#274e13" face="comic sans ms, sans-serif"><br></font></div><div class="gmail_default"><font color="#274e13" face="comic sans ms, sans-serif">Thank you all so much for the feedback and support, I look forward to exploring where</font></div><div class="gmail_default"><font color="#274e13" face="comic sans ms, sans-serif">we can go with this proposal and making Swift 4 the best release yet.</font></div><div class="gmail_default"><font color="#274e13" face="comic sans ms, sans-serif"><br></font></div><div class="gmail_default"><font color="#274e13" face="comic sans ms, sans-serif">Forever your Swift Evolution buddy,</font></div><div class="gmail_default"><font color="#274e13" face="comic sans ms, sans-serif"><br></font></div><div class="gmail_default"><font color="#274e13" face="comic sans ms, sans-serif">   - Nick</font></div><div class="gmail_default"><font color="#274e13" face="comic sans ms, sans-serif"><br></font></div><div class="gmail_default"><br></div></div>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div></div>