<div dir="ltr">Interesting proposal, I think there's value in exploring this, it certainly seems logical. I'd like to see the impact on an existing codebase and if there's any savings/conveniences/issues.<div><br></div><div>My main concerns, mostly that Swift is not yet ready for it:</div><div><div> * How does this compare semantically when used in an if/guard statement?</div></div><div><div> * If higher kinded types are introduced should "<span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px">Optional</span><span style="font-family:Menlo;font-size:11px;color:rgb(0,0,0)"><</span><span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px">Int</span><span style="font-family:Menlo;font-size:11px;color:rgb(0,0,0)">></span>" be of a kind with "<span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px">Bool</span>"<span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px"> </span>?</div></div><div> * Optional casting rules need some work still, in my opinion.</div><div> * How does this relate to "<span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px">ImplicitlyUnwrappedOptional<Void></span>"<span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px"> </span>? they seem sometimes interchangeable with "<span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px">Optional<Void></span>".</div><div> * As you mentioned, but in more detail:<br></div><div> + Making it conform to "<span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px">BooleanType</span>", "<span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px">BooleanLiteralConvertible</span>"<span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px"> </span>is not yet possible:</div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><b>error: same-type requirement makes generic parameter 'Wrapped' non-generic</b></p></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">extension</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(112,61,170)">Optional</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">where</span><span style="font-family:Menlo;font-size:11px"> Wrapped == Void { </span><span style="font-family:Menlo;font-size:11px;color:rgb(0,132,0)">/*...*/</span><span style="font-family:Menlo;font-size:11px"> }</span></div></blockquote></blockquote><div> + Can we, or even should we specialise <span style="font-family:Menlo;font-size:11px">debugDescription<font color="#703daa"> </font></span>for <span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px">CustomDebugStringConvertible </span>?</div><div> * Assuming the generic is equivalent to this:<br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(112,61,170)"><span style="color:rgb(187,44,162)">enum</span><span style="color:rgb(0,0,0)"> Bool: </span>BooleanType<span style="color:rgb(0,0,0)">, </span>BooleanLiteralConvertible<span style="color:rgb(0,0,0)"> {</span></p></div><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">case</span> Some()</p></div><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:rgb(187,44,162)">case</span> None</p></div><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</p></div></blockquote><div> + Will that be optimised to the same extent as Bool?</div><div> + Will it be packed as efficiently as Bool (Int1)?</div><div> + Is "<span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">let</span><span style="font-family:Menlo;font-size:11px"> myBoolean = .None</span>" confusing? should it be allowed?</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 17, 2015 at 9:25 PM, Brent Royal-Gordon via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This is less a proposal and more a vague notion, but here goes.<br>
<br>
Occasionally, Optional<Void> comes up in Swift. This particularly happens with optional chaining (and its socially awkward twin `Optional.flatMap(_:)`), but I occasionally see it come up in other places, particularly where you’re using a Result-ish type. Wherever it does come up, it seems to have the same semantic meaning as Bool, with `nil` meaning `false` and `()` meaning `true`.<br>
<br>
Does it make sense to somehow unify them? Perhaps turn Bool into a typealias for Optional<Void> and move all of its conformances into (not yet supported) conditional conformances on Optional?<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Brent Royal-Gordon<br>
Architechies<br>
<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">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>
</font></span></blockquote></div><br></div>