167 points · by okket · 9y ago · 69 comments
To me that seems like a nice way of doing it - warning developers about approaching changes with a fairly strong warning message, and allowing time for those changes to take place.
There were also some new warnings added for mixed type arithmetic which is a common source of surprising behavior.
The initialize thing is as far as I understand due to a limitation in the Objective C runtime and overriding initialize in Swift never fully worked in the first place.
If you feel the 3.0 to 3.1 migration was still too painful from a compatibility perspective, it is not too late to file bugs; Swift 4 will still remain compatible with Swift 3 source so we can make further adjustments to the type checker if needed.
At first it seemed 'snappier' but starting to notice not much of an improvement.
It definitely still feels like making small changes like changing a function name triggers a lot of extra work.
I should fire up some benchmarking of Swift 3.1 vs 3.0
There was some work on the expression type checker in 3.1 (string interpolation, casts and a limited "domain shrinking" pass to simplify some arithmetic expressions) but the main focus there was centered on the declaration checker, in particular up the generics implementation to fix lots of crashes and limitations.
Both the expression checker and incremental builds should receive more attention going forward though.
In the meantime the usual workarounds might help - splitting up your codebase into multiple Swift modules ("targets" in Xcode), and splitting up complex expressions and adding explicit type annotations.
https://github.com/apple/swift/commit/5b9166ba8098a23e0601aa...
https://github.com/apple/swift/commit/5b9166ba8098a23e0601aa...
After turning it on compilation speed seemed to improve immensely
https://developer.ibm.com/swift/
func drop(while predicate: (Self.Iterator.Element) throws -> Bool) rethrows -> Self.SubSequence
I take it the "throws" on the type of predicate means it can 'throw/return' an error. Why would you do this? Why not just require your predicate function to be able to process any element?Or I am confused?
It seems like the equivalent in Go, for example, would be something like this
func drop(seq []T, while func(T) (bool, error)) ([]T, error)
which, again, seems like madness.Or am I confused?
The equivalent Go code would then (presumably) be these two methods:
func drop(seq []T, while func(T) (bool)) ([]T)
func dropWithError(seq []T, while func(T) (bool, error)) ([]T, error)
If you pass in a closure that throws (i.e., can return an error) then the compiler will require try/catch error handling at the `drop()` method call site.If you pass in a closure that does not throw then compiler will assume that `drop()` does not throw.
You can write higher order functions that only take total functions as arguments and handle errors with an 'Either' type, which is more general but creates boilerplate.
Also 'rethrows' is a special keyword that means if you pass in a function that does not throw, the overall operation won't throw either. So mapping over an array of integers to increment each one won't require error handling, since the operation itself cannot fail.
Nitpick: in Swift, "since the operation itself cannot fail" isn't correct. The operation will fail on overflow, but it will terminate your application rather than throw.
Because otherwise you can't use partial functions as predicates which is an unnecessary an oft annoying limitation, in my experience it's one of the biggest pains in the ass in Java and a major reason why its checked exceptions system was unusable: you couldn't create "transparent" functions (and interfaces) with respect to CE.
> It seems like the equivalent in Go, for example, would be something like this
`rethrows` is a transitive property, if the predicate is not a throwing function, the HoF isn't one either. So you'd need two functions in Go. And then `drop` works on a more abstract concept than concrete array slices ("Sequence" is what many other languages would call an iterable).
Because the predicate would then have to swallow any exceptions thrown downstream. What would it return in that case? True or false?
Second, if you pass a predicate that is not declared `throws`, then the compiler treats `drop(while:)` as if it cannot throw either. This is what `rethrows` means: it makes `drop(while:)` covariant (in terms of throws-ness) with `predicate`.
Maybe I just don't have written with it enough.
It's incredibly slow, it has always been riddled with bugs, it has crashed on me more often than any other software, and it is lacking so much functionality that it doesn't deserve to be called an IDE at all.
For instance, it can't even rename a Swift function years after Swift's introduction.
SourceKit should help XCode to reason about Swift code but somehow XCode gets lost at least once or twice a day on my machine (MBP 15" i7, 16GB RAM).
Android development tools used to suck but since Android Studio 2.0 and the rise of Swift, it is now iOS dev tools that are lagging behind.
Yep. Happens to me all the time too. Make some changes to code, then wait half a second of the syntax coloring to take effect.
How this is not instant boggles the mind. Maybe it's related to SourceKitService which randomly decides start taking up 100% CPU for no discernible reason.
I don't like the IDE itself... for instance, if I need to rename something, Xcode uses an XML that when you have a team working on the same project, you will have huge problems with merge the commits.
Maybe the problem is me, but, I know XCode since 2012 and I never like it! =l
http://stackoverflow.com/questions/42045139/i-want-a-compile...
Seems like a pretty easy mistake to make, since third party libraries I use were littered with exactly the same mistake.
https://swift.org/builds/swift-3.1-release/ubuntu1610/swift-...
https://swift.org/builds/swift-3.1-release/ubuntu1604/swift-...
https://swift.org/builds/swift-3.1-release/ubuntu1404/swift-...
And all the action these days is on the master branch so if you're on Linux and want to help us squash regressions you should periodically test your codebase with master snapshots.
It would be great, if there was a tag+source tarball for each release. I'm sure internally there must be something, your colleagues certainly must know, to which commit 'Apple Swift version 3.1 (swiftlang-802.0.48 clang-802.0.38)' maps to.