[swift-evolution] Rename 'guard' to 'ensure'

Dave Abrahams dabrahams at apple.com
Mon Feb 22 13:00:41 CST 2016

on Mon Feb 22 2016, David Waite <swift-evolution at swift.org> wrote:

>> On Feb 22, 2016, at 11:15 AM, Dave Abrahams via swift-evolution
>> <swift-evolution at swift.org> wrote:
>> on Mon Feb 22 2016, Erica Sadun <swift-evolution at swift.org> wrote:
>>>> " a vision of a little guard standing at his guard post checking papers"
>>> Raises hand. Me too. I like my little guard.
>>> On the other hand, I'd love if assert/precondition would be combined
>>> into a single call, with an optional `forReleaseBuild:` arg (better
>>> named) that defaults to false.
>> I really don't want to do that.  Assert and precondition have different
>> use-cases, and I don't want people to ask “do I want this on in a
>> release build?” (which is a hard decision to make correctly and
>> consistently) when they write them.  I want them to ask, “Am I checking
>> whether this method is being called correctly or is this just a
>> self-sanity check?”
> Agreed. There are (usually very unfortunate) reasons for me to turn on
> self-sanity checks for release builds, as well.

Having the ability to do that is something I would support.

> There is also the possibility of an assert/precondition having
> side-effects, and people being confused that the forReleaseBuild:false
> version never calls their code at all. This is exasperated IMO since
> the methods use @autoclosure.

exacerbated, yes.


More information about the swift-evolution mailing list