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

David Waite david at alkaline-solutions.com
Mon Feb 22 12:27:35 CST 2016


> 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.

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.

-DW

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4139 bytes
Desc: not available
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160222/5d4e5868/attachment.p7s>


More information about the swift-evolution mailing list