Other than access control,1 no big changes to the language with Beta 4, unlike with Beta 3. But still plenty of changes to the standard library.
Some small bits and pieces:
Float
andDouble
are no longer random access indices. Who was planning on indexing a collection with aDouble
, anyway? Just how big was your collection going to be?2uppercaseString
andlowercaseString
properties are gone fromString
. I never liked them. Call a function a function, that’s what I say.insertionSort
andquickSort
are gone. Generic non-name brand sorts only from now on.- Instead of having static members for
true
andfalse
,Bool
now implements the newBooleanLiteralConvertible
protocol CString
is gone. You can still construct strings from c-style strings, but those now take aConstUnsafePointer
. Probably to discourage people from keeping the nasty little things hanging around in their native primordial form.remainderWithOverflow
replacesmodulusWithOverflow
- Yet more types are reflectable, and there’s now an enum value to represent Objective-C objects separate from Swift ones.
Now the bigger changes…
ArrayBuffer
, ArrayBufferType
, SliceBuffer
and ContiguousArrayBuffer
are gone. It was kinda surprising they were there in the first place, revealing the inner workings of Array
. Sorry if you spent some time figuring out how to use them, but you probably had no business poking around in there. As a result, the makeUniqe
member functions are also gone.
reverse
is no longer lazy. It now gives you back an Array
. Huh. Looks like if you really want to reverse something lazily, you now need to create a LazyBidirectionalCollection
via a call to lazy()
, then call .reverse()
on it to get another lazy collection. Bit cumbersome, but probably more explicit.
There’s also LazyForwardCollection
, LazyRandomAccessCollection
, and LazySequence
. lazy()
will return the appropriate one from your base collection or sequence. All of them give a base the ability to map and filter, plus conversion to an array. Only the bidirectional and random ones can be reversed, obvs. And the random access one has a subscript. I guess I need to update my article on lazy collections and sequences.
Range
is no longer sliceable. I don’t really “get” sliceable, but what I do get suggests Range
shouldn’t have been sliceable.
Speaking of ranges, were you trying to use Range
with floating-point types? Well cut that out and use StrideTo
and StrideThrough
instead, both created with a call to stride
(with either a to
or a through
as the second argument name). They mirror respectively a half-open and closed version of Range
. The big difference being if your stride length takes you past the end, they stop striding.
The version of filter
that took a collection not a sequence is gone. It was a bit pointless anyway, since you can’t index randomly into a filtered collection without doing all the filtering up to that point. And the sequence version is no longer lazy, it returns an Array
. If you want to filter lazily, use the explicitly lazy stuff above. If you want to filter starting from the back, you can do lazy().reverse().filter()
As ever, I refrain from commenting on anything relating to Unicode and Objective-C bridging, for fear of demonstrating my ignorance.
[…] airspeedvelocity.net […]
[…] Airspeed Velocity: […]
[…] of beta 4 changes. Look at Airspeed Velocity and Erika Sadun’s lists. To me the major changes are finally getting an equivalent to #pragma […]