78 points · by ingve · 7y ago · 22 comments
This probably doesn't matter much when making iOS apps, but it would make swift much more useful in other domains (like as a web server).
> [...] there are already substantial improvements to RC optimization in 5.1 (and even more in top-of-tree). Using Unmanaged is "cheating" in a sense because it's unsafe, and it should not be necessary in normal circumstances to get adequate performance from idiomatic code—if it's safe to use unmanaged references, then the compiler should know that and avoid reference counting in the first place. The current Swift implementation is still nowhere near representative of the performance that should be possible, since we've been primarily in the "make it work" phase of development, and are only now starting to get into the "make it fast" work.
Swift 5.1 enables the creation of binary frameworks that can be shared with others leveraging the language’s added support for module stability.
func add(_ x:Int, _ y:Int) -> Int { x + y }
let z = add(2,2)
Might not seem big, but it's nice to removed unneeded boilerplate.let z = add(x:2, y:2)
Are there other languages with this type of method declaration/use site syntax? If so, what's the advantage?
Wait, so if I wrote my own custom enum with .some and .none cases this will not work correctly? This seems like an overly broad scope; why can't the change have only affected Optional.some and Optional.none?
public extension Sequence where Element: Identifiable {
func keyedByID() -> [Element.ID : Element] {
var dictionary = [Element.ID : Element]()
forEach { dictionary[$0.id] = $0 }
return dictionary
}
}
Perhaps this could use Dictionary(grouping:by:)?If you use any language long enough you will think, hey it would be nice to have X. Alejandro (in high-school at the time) thought exactly that and implemented it himself - https://github.com/apple/swift-evolution/blob/master/proposa...
You could almost argue the real feature here is how open the community is to additions like this, and there's no need to wait for people at Apple to do it.