[swift-evolution] An implicit return for guard

Xiaodi Wu xiaodi.wu at gmail.com
Mon Jun 20 11:08:24 CDT 2016


On the contrary, having a compiler error for a guard body that doesn't exit
the scope is the very point of having guard.

The links were for your review because the discussion on this idea has been
extensive and both times reached consensus that this is not a workable idea.


On Mon, Jun 20, 2016 at 09:12 Yarden Eitan via swift-evolution <
swift-evolution at swift.org> wrote:

> Adrian: I would prefer to not have it at all. But this is a better
> alternative than a brand new line declaring a return, and nothing else.
> This is inline and part of the ‘guard’ declaration (better context), and
> definitely better than having a warning stay in your codebase.
>
> Putting the code clarity aside, having a compiler error for a non-returned
> guard seems like an overkill, and different that the other Swift
> implementations (such as Switch that doesn’t need a break to not fall
> through).
>
> Xiaodi: Thank you for the links. Was an actual proposal ever formed for
> this, or was it decided not to move forward?
>
> Yarden
>
>
>
> On June 20, 2016 at 1:33:54 AM, Adrian Zubarev via swift-evolution (
> swift-evolution at swift.org) wrote:
>
> @implicitreturn guard a = b else { print(“foo”) }
>
> Isn’t that just the same? I mean now you even write more boilerplate then
> bebore.
>
> How does your return type look, what are you trying to solve?
>
>
> --
> Adrian Zubarev
> Sent with Airmail
>
> Am 20. Juni 2016 um 08:30:39, Yarden Eitan via swift-evolution (
> swift-evolution at swift.org) schrieb:
>
> @implicitreturn guard a = b else { print(“foo”) }
>
> _______________________________________________
> 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/20160620/0eabdc4d/attachment.html>


More information about the swift-evolution mailing list