Apple’s new programming language, “Swift,” received some nice Beta 3 love today, right along with the new betas of Xcode 6 and OS X Yosemite. The new language received major improvements designed to fix previous code inconsistencies, and to prevent code issues that arose in previous versions.
Apple has also updated their “Introducing Swift” ebook, available free in iBooks, to reflect the changes.
Important Changes, Issues Resolved in Xcode 6 Beta 3
Swift Language
The online Swift Programming Language documentation and book has been updated. See: https://itunes.apple.com/us/book/the-swift-programming-language/id881256329?mt=11!
- Array in Swift has been completely redesigned to have full value semantics like Dictionary and String have always had in Swift. This resolves various mutability problems – now a ‘let’ array is completely immutable, and a ‘var’ array is completely mutable – composes properly with Dictionary and String, and solves other deeper problems. Value semantics may be surprising if you are used to NSArray or C arrays: a copy of the array now produces a full and independent copy of all of the elements using an efficient lazy copy implementation. This is a major change for Array, and there are still some performance issues to be addressed. Please see the Swift Programming Language for more information. (17192555)
- The Array and Dictionary “sugar” syntax has been redesigned: You now declare arrays as [Int] instead of as Int[], as shorthand for Array<Int>. The old syntax made sense when arrays had semantics closer to C arrays, but would be misleading with the new value semantics approach. Along with this, Dictionary syntax has improved so that [Key:Value] is treated as sugar for Dictionary<Key,Value>. Both of these are now consistent with each other and with the literal syntax used to build an array or dictionary. Please see the Swift Programming Language for more information.
- NSDictionary* is now imported from Objective-C APIs as [NSObject : AnyObject]. (16870626)
- The half-closed range operator has been changed from .. to ..< to reduce confusion and ambiguity. Now the two range operators are ..< and … for half-closed and closed ranges, respectively (17203527). nil is now a literal in the language, not a global constant of _Nil type. This change resolved a number of problems with nil; e.g. nil in a collection, nil converting to Any, etc. Types can now indicate that they are nil compatible by conforming to the NilLiteralConvertible protocol. (16951729)
- APIs imported from C no longer use type aliases like CInt or CFloat, which obfuscated the underlying type. They are now imported as Int32 and Float, etc.
- APIs imported from C that use C pointers are now imported with a much simpler API type structure which is more predictable, preserves const mutability in more cases, and preserves __autoreleased pointer information. Now you will see UnsafePointer, ConstUnsafePointer, AutoreleasingUnsafePointer, etc. Function pointers are also imported now, and can be referenced and passed around. However, you cannot call a C function pointer or convert a closure to C function pointer type.
For more information, see the Xcode 6 Beta 3 Release Notes. (PDF)
(Via 9to5Mac)