[swift-evolution] proposal for a even simpler guard.. => guard!

Xiaodi Wu xiaodi.wu at gmail.com
Tue May 3 01:47:33 CDT 2016


Besides the legacy operator `!=`, isn't virtually every place you see !
potentially fatal, for some definition of potential? ;)
On Tue, May 3, 2016 at 01:41 Dominik Pich via swift-evolution <
swift-evolution at swift.org> wrote:

> ;) yes. I know I can write let x = y! but IMHO THAT is too brief again.
> I like the fact that *guard *makes you look what you do… it is a little
> bit like assert(x != nil)
>
> guard! let x = y
>
> it reads awesome and everybody can more easily see it is a potentially
> fatal & important call
>
> On May 3, 2016, at 1:38 AM, Jordan Rose <jordan_rose at apple.com> wrote:
>
> We have that; it’s just ‘!’. :-)
>
> Jordan
>
> On May 2, 2016, at 12:09, Dominik Pich via swift-evolution <
> swift-evolution at swift.org> wrote:
>
> Hello,
> often the guard statement is used to only unwrap optionals. multiple
> guards will cause a lot of ‘overhead’.
> also often if it doesn’t work. there is no easy way we can gracefully
> recover ;)
>
> so how about we do the same as with try/catch where you can use try! and
> have a guard!
>
> the *guard!* could just throw an exception …
>
> regards
> Dominik
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160503/ed2b78c7/attachment.html>


More information about the swift-evolution mailing list