Hey, happy Monday, none of your Swift code will compile!
Nothing a quick find and replace can’t cure. “Several” protocols have been renamed with the -Type suffix to avoid confusion, say the release notes. “A crapload” may have been a more accurate term but that probably wouldn’t pass Apple QA. Mostly this is a lot clearer – especially with
IntegerType, as there were lots of confused beginners wondering why they couldn’t declare an
Unmentioned, but in a similar vein in the opposite direction, various typealiases within protocols have had their
Type suffix removed.
SliceType are now just
This I guess makes up for the extra verbosity of now having to type
CollectionType that bugs me a bit, though it will give me a reason to just write “collection” in future articles without always feeling guilty that I haven’t capitalized and monospace-fonted it.
A quick list of small items:
- All the operators declared at the top now have visible precedence levels and associativity, which is handy if you are trying to target the precedence of your own operators.
- Lots of new operators for strides and intervals.
- The weird use of
Optionalis gone, as has
Characteris now hashable.
- The trend of replacing proxies of C-style things with pointer objects, that started last beta with replacing
CString, continues with
- The law finally caught up with
Arrayand made it mark its various mutable methods as mutable. Same for
- Various integer types have had the
getArrayBoundValuefunction changed to an
Stringnow has inits that take integers. You can also supply a radix, as well as whether you want digits above 9 to be in upper or lower case.
- In addition to
last, the lazy collections also implement
lastif they can index bidirectionally), as well as
- There’s also a non-member
isEmptythat takes a collection, and a
lastthat takes a collection if it has a bidirectional iterator.
Optionalnow has a
hasValueproperty instead of a
asSigned()has gone. Instead, use
numericCastwhich appears to have been revamped a bit to do more at compile time.
UIntnow has a bitwise initializer from its signed equivalent, which you need to explicitly call with a
reinterpretCasthas been renamed
unsafeBitCast. You have been warned.
suffixfunctions take a
Sliceableand return the start or end of it as a slice.
- You can no longer access the underlying sequences of a
- There’s now a version of
assertthat takes a
BooleanTypeexpression, not just a bool.
- The comment descriptions for
sortnow have a helpful link to wikipedia about strict weak ordering!
- The function passed to
xas an argument now.
Range has been thoroughly demoted. One minute it’s on top of the world, then last time
stride takes its spot for non-contiguous increments. Now
HalfOpenInterval replace it for general purpose ranges. They also follow the pattern adopted by
StrideThrough of having completely different types for the two kinds, determined at compile time. They require their initializing values to conform to
ComparableType, which means they can detect if they are inverted and can efficiently detect overlap between two intervals.
Range is now relegated entirely to managing collection indices. The odd thing about this is that
Int, probably the most common thing to use to initialize a range, is also an index type, so
Range still gets to come out and play all the time.
By the way, I love how the definitions of
StrideThrough have a FIXME in their comments about how they ought to be collections.
Finally, ever wonder why when you declared your class to be a
Collection, you got chewed out by the compiler for not implementing
_Collection? Well out of the shadows emerges the (newly renamed)
_CollectionType. Here you will find the missing bits of what made collections work –
IndexType etc. Same goes for
_IntegerArithmeticType etc. It’s not clear why these aren’t just pulled up into their non-underscore equivalents, but at least now you can go look at them instead of having to reverse-engineer what you needed to implement.