[swift-evolution] guard let x = x

Joshua Alvarado alvaradojoshua0 at gmail.com
Wed Oct 26 12:23:37 CDT 2016


In your example the keyword only makes sense if you are shadowing the
optional variable. How would unwrap work with a different name?

Ex:
guard let bar = foo else {...}
guard unwrap bar else {...} -> There is no context to what the guard is
unwrapping
This could end up leading to:
guard unwrap bar = foo else {...} which is essentially the same as the
current guard

Alvarado, Joshua

On Wed, Oct 26, 2016 at 11:09 AM, Josh Parmenter via swift-evolution <
swift-evolution at swift.org> wrote:

>
> On Oct 26, 2016, at 9:37 AM, Chris Lattner via swift-evolution <
> swift-evolution at swift.org<mailto:swift-evolution at swift.org>> wrote:
>
> To me, this is the most promising direction, but I’d suggest the use of
> “unwrap" as the keyword.  If you compare these two:
>
> a) guard let foobar = foobar else { … }
> b) guard unwrap foobar else { … }
>
> I think that b) wins by virtue of eliminating repetition ("foobar =
> foobar" fails DRY principles), but retains clarity by introducing a word
> into the grammar that people already commonly know and use, and which is
> googlable if they don’t.
>
> I find b) to be quite convincing.
>
> Best,
>
> Josh
>
>
>
> Joshua Parmenter | Engineering Lead, Apple Technologies
>
> T 248 777 7777
> C 206 437 1551
> F 248 616 1980
> www.vectorform.com<http://www.vectorform.com/>
>
> Vectorform
> 2107 Elliott Ave Suite 303
> Seattle, WA  98121 USA
>
> Think Tank. Lab. Studio.
> We invent digital products and experiences.
>
> SEATTLE | DETROIT | NEW YORK | MUNICH | HYDERABAD
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>



-- 
Joshua Alvarado
alvaradojoshua0 at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161026/170e3478/attachment.html>


More information about the swift-evolution mailing list