[swift-evolution] [Proposal] Remove Boolean

Anton Zhilin antonyzhilin at gmail.com
Thu Jun 23 16:33:22 CDT 2016


Following goals of Swift 3, I've prepaired a minimalistic proposal to 
remove Boolean protocol.

https://github.com/Anton3/swift-evolution/blob/remove-
boolean/proposals/NNNN-remove-boolean.md

## Introduction

Remove `Boolean` protocol. Only Bool will be able to be used in logical 
contexts:

let x: ObjCBool = true
if x {  // will become an error!
  ...
}

## Motivation

"Boolean" isn't pulling its weight:
- It only abstracts over Bool and ObjCBool.
- It only enables a few operations on ObjCBool, which are not very 
important.
- ObjCBool is a bridging problem, and we don't handle bridging by 
introducing common protocols (e.g. in the case of String vs NSString, we 
don't introduce a common "Stringable" protocol.

Further, it complicates the model:
- People are confused by it and the similar but very different Bool 
type.
- Bool is a simple enough concept to not need a family of protocols.

## Impact on existing code

Change is backwards incompatible, but automatic migration is possible:

- In places where Boolean (but not Bool) was in logical contexts, 
migrator can add `.boolValue`
- Migrator can remove conformances to Boolean



More information about the swift-evolution mailing list