Congratulations to the Swift team on releasing a 1.0 GM! Unsurprisingly, there were no changes that I could spot1 between beta 7 and the GM standard libraries.
But as they said in their blog post, “Swift will continue to advance with new features, improved performance, and refined syntax. In fact, you can expect a few improvements to come in Xcode 6.1 in time for the Yosemite launch.” As such, the first beta of Xcode 6.12 saw more changes to the standard library than we saw in the pre-1.0 beta, and here they are:
- As flagged in the release notes, all the integer types have acquired
truncatingBitPatterninitializers for each of their larger counterparts. - The functions
join,reduce,sortandsortedhave acquired descriptions in the various places they’re implemented. AssertStringandStaticStringare nowPrintableandDebugPrintableHeapBufferStorageno longer inherits fromHeapBufferStorageBase, which is gone.- The
Processinstance is now declared withletrather thanvar StrideThroughorStrideToare nowReflectableStaticStringnow has autf8Startinstead ofstart(which still returns anUnsafePointer). It also has awithUTF8Buffermethod for using the underlying raw buffer, aunicodeScalarget property.Stringhas lost itscompare(other: String.UnicodeScalarView)method.Stringalso now implements several methods extendingStringInterpolationConvertible– for a variety of different built-in types.- Second versions of
assertionFailureandfatalErrornow take a genericAssertStringTypeinstead ofStaticString. equalandstartsWith‘s predicate functions have been renamedisEquivalent.maxElementandminElement‘s input parameter has been renamedelements.- The
toStringfunction now says it returns the result ofprinting, notdebugPrinting, an object.
There’s a new unsafeAddressOf function that takes an AnyObject. Apparently there’s “not much you can do with this other than use it to identify the object”.
There is a new protocol, UnicodeScalarLiteralConvertible, that follows the now-familiar literal converter pattern: a ThingType typealias, a convertFromThing class function, and a library-level typealias for ThingType for the standard type for these literals to convert into, in this case a String.
The ExtendedGraphemeClusterLiteralConvertible protocol now inherits this protocol, so the objects that implement it (Character, String, AssertString and StaticString) also now implement convertFromUnicodeScalarLiteral. And the UnicodeScalar struct now implements UnicodeScalarLiteralConvertible instead of ExtendedGraphemeClusterLiteralConvertible.
Here’s looking forward to more enhancements as Swift continues to develop.
Excellent summary, as always. I also found out the hard way that String no longer conforms to the Printable protocol in 6.1 beta.
[…] Airspeed Velocity: […]