News for hackers. Stuff that matters.
Re:The Next Step for Generics by nurettin on Tuesday June 16, 2020 @06:48PM (#23545261)
Substituting null with optional helps with getting a stack trace of what's going on. However, it doesn't get rid of programming errors.

What does get rid of errors is IDE support for nullable types which warns the programmer that they have accessed a property without checking for nulls. Take kotlin and Intellij/IDEA for instance.

Re:The Next Step for Generics by nemothekid on Tuesday June 16, 2020 @07:18PM (#23545534)
An optional is the compiler telling me to check for nulls. My program won't compile if I don't check for nulls.

IDE support is half baked, someone can always turn it off.

Re:The Next Step for Generics by nurettin on Wednesday June 17, 2020 @04:52AM (#23549277)
This doesn't sound right. Could you paste an example of a misuse of optional (for example: an unchecked unwrap) causing a compilation failure instead of a panic?
Re:The Next Step for Generics by jpttsn on Wednesday June 17, 2020 @01:11PM (#23553878)
In Swift `let x = things.first` won't compile but `let x = things.first ?? "empty"` and `let x = things.first!` will. Does that count?

(Probably mangled the Swift, doing this from memory)

Re:The Next Step for Generics by nurettin on Thursday June 18, 2020 @05:07AM (#23561236)
My swift isn't good, but since you didn't specify a type for x, I think it should compile anyway. But if things is an empty array of T, first may return nil and x will be of type T?. If things is an array of optional, x will be of type T??