Why no DoubleWidth<T> in Xcode 9.3 beta 2?

(Jens Persson) #1

Why is DoubleWidth<T> not available in the default toolchain of Xcode 9.3 beta 2?

It is and has been available for a long time in recent dev snapshots.

And it says “Implemented in Swift 4” in the proposal status.

(Xiaodi Wu) #2

It’s not done yet :)

(Jens Persson) #3

The proposal status changed into “Implemented (Swift 4)” on Sep 3, 2017 (almost half a year ago), and we’re currently not only at Swift 4.0, but Swift 4.1, and it’s been in the dev snapshots for a very long time (perhaps 5 months?).

In what way do you mean it isn’t done yet?

(Xiaodi Wu) #4

I know that it says “Implemented (Swift 4)” for the revised integer protocols, but that’s only mostly true, for the commonly used parts. There are still gaps in implementation and documentation that are to be addressed, hopefully all in time for Swift 5.

DoubleWidth is now reasonably complete, but until only a few weeks ago, dividing two values of type DoubleWidth<DoubleWidth<DoubleWidth<DoubleWidth<Int>>>> would take entire seconds.

(Max Moiseev) #5

Not to mention other issues, like the standard library binary size, that we could not address in time.

(Jens Persson) #6

Ah, ok, thank you both!

(Andrew Trick) #7

DoubleWidth compile time.

There are multiple severe compilation problems generating code for this type. I don’t think we should add it to the stdlib without a usable implementation.

(Alexander Momchilov) #8

Can someone please ELI5 why this type blew up the compiler, for someone who's never working on the compiler before?

I can see why a type like this would need a lot of specializations done (the whole salespitch of this type relies on it being fast enough to be worth using over a general BigInt library), but I don't understand why they would take (what appear to be) non-linear time to do.