<div dir="ltr">On 11 October 2017 at 18:30, Mike Kluev <span dir="ltr">&lt;<a href="mailto:mike.kluev@gmail.com" target="_blank">mike.kluev@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">&gt; On 7 Oct 2017, at 04:24, Chris Lattner via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
&gt;<br>
&gt;&gt; These aren’t the forms I was suggesting, what I meant was:<br>
&gt;<br>
&gt; extension Int {<br>
&gt;   init(randomInRange: Countable{Closed}Range&lt;Int&gt;)<br>
&gt; }<br>
&gt;<br>
&gt; which gives:<br>
&gt;       let x = Int(randomInRange: 0..&lt;5)<br>
&gt;<br>
&gt; The point of this is that you’re producing an Int (or whatever type).  Regardless of whether the initializer is failable or not, this is the preferred way of creating a new value with some property: it is an initializer with a label.<br></blockquote><div><br></div><div>or make it a non-initialiser: let x = Int.random or Int.random()</div></div></div></div></blockquote><div><br></div><div>on the positive side would be ability to omit types in many cases:</div><div><br></div><div>foo(_ x: Int) { ... }</div><div><br></div><div>foo(.random)   // Int.random inferred</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>have you guys considered: func random&lt;T&gt;(...) -&gt; T</div><div>where it returns a different type based on a context?</div></div></div></div></blockquote><div><br></div><div>or &quot;foo(random())&quot; here,  random&lt;Int&gt;() inferred</div><div><br></div><div>the latter case opens wide opportunities for strict type/range checking, e.g.:</div><div><br></div><div>if &quot;angle&quot; is a variable ranging from 0 .. 2*pi then</div><div><br></div><div>angle = random()   // is inferred as a 0 .. 2*pi range without me typing anything</div><div><br></div><div>Mike</div><div><br></div></div></div></div>