Skip to content

Commit 6e17e06

Browse files
committed
Add FAQ
1 parent 9d0e8b2 commit 6e17e06

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,29 @@ pons/pocomplex.swift:13:5: warning: use of 'typealias' to declare associated typ
103103
```
104104
105105
Just ignore them for the time being. They are needed in 2.1.
106+
107+
## FAQ
108+
109+
### Q. Swift already has tons of protocols built-in like [IntegerType] and [FloatingPointType]. Why do you reinvent these?
110+
111+
[IntegerType]: http://swiftdoc.org/v2.1/protocol/IntegerType/
112+
[FloatingPointType]: http://swiftdoc.org/v2.1/protocol/FloatingPointType/
113+
[IntegerArithmeticType]: http://swiftdoc.org/v2.1/protocol/IntegerArithmeticType/
114+
[Comparable]: http://swiftdoc.org/v2.1/protocol/Comparable/
115+
[AbsoluteValuable]: http://swiftdoc.org/v2.1/protocol/AbsoluteValuable/
116+
117+
A. I wish I could. As a matter of fact I tried to do so when I started. It turns out the protocol tree Swift 2.1 offers is not fit for the Protocol-Oriented Number System. For instance, [FloatingPointType] lacks arithmetic operators. They can be found in [IntegerArithmeticType] but it includes `%`, something that is not essential for real-number arithmetics
118+
119+
Besides, where are you going to fit `Complex`? It is the queen of the numbers but definitely not [Comparable]. It is absolute-valuable but Swift says [AbsoluteValuable] is also [Comparable].
120+
121+
I am pretty sure Swift insiders are aware of this issue that should be addressed. I found the following in the [swift-evolution] mailing list.
122+
123+
> I have been working for some time on a rewrite of all the integer types and protocols <https://github.com/apple/swift/blob/master/test/Prototypes/Integers.swift.gyb>. One goal of this effort is to enable operations on mixed integer types, which as you can see is partially completed. In-place arithmetic (anInt32 += aUInt64) is next. Another important goal is to make the integer protocols actually useful for writing generic code, instead of what they are today: implementation artifacts used only for code sharing. As another litmus test of the usefulness of the resulting protocols, the plan is to implement BigInt in terms of the generic operations defined on integers, and make BigInt itself conform to those protocols.
124+
125+
[swift-evolution]: https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151214/002445.html
126+
127+
Maybe I am a litte too impatient. But here it is.
128+
129+
> [Impatience]: The anger you feel when the computer is being lazy. This makes you write programs that don't just react to your needs, but actually anticipate them. Or at least pretend to.
130+
131+
[Impatience]: http://threevirtues.com

0 commit comments

Comments
 (0)