[swift-evolution] [pitch] rename 'guard' to 'ensure'

Jay Abbott jay at abbott.me.uk
Tue Oct 25 12:18:38 CDT 2016


>
> I don’t read “*Guard that x is higher than 0 else … *”, but instead I
> read it like “*Guard! x must be higher than 0 else …*”.
>
>
I see, yes I hadn't considered this interpretation...


>
> Probably adding a colon could make it more clear to the reader:
>
> guard: x > 0 else {
>     return
> }
>
> But then we risk to add complexity to the syntax.
>

I actually like this better than ensure - it makes a lot of sense. It would
also force the second interpretation as you mentioned above. If 'guard' was
simply renamed to 'guard:' (or depending on how you look at it, required to
have a colon after it), how would it complicate the syntax?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161025/a6388b7b/attachment.html>


More information about the swift-evolution mailing list