For example:
if a > 0 {
….
} else a < -5 {
…
}
This would be the same as:
if a > 0 {
….
} else {
precondition(a < -5)
…
}
For example:
if a > 0 {
….
} else a < -5 {
…
}
This would be the same as:
if a > 0 {
….
} else {
precondition(a < -5)
…
}
My first thought was that at first glance I'd get this confused with "else if". Obviously that doesn't change semantics in correct code, but it does seem a little subtle.
My second thought was "precondition or assert?" (i.e. "is the check enabled in release builds?") and that convinced me that this wasn't really worth the added complexity. It's a neat idea, but I think the language becomes more complex because of it without sufficient gain.
Jordan
On Dec 8, 2015, at 5:47, Amir Michail via swift-evolution <swift-evolution@swift.org> wrote:
For example:
if a > 0 {
….
} else a < -5 {
…
}This would be the same as:
if a > 0 {
….
} else {
precondition(a < -5)
…
}_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution
How is this different from `else if`?
if a > 0 {
...
} else if a < -5 {
...
}
Pozdrawiam – Regards,
Adrian Kashivskyy
Wiadomość napisana przez Amir Michail via swift-evolution <swift-evolution@swift.org> w dniu 08.12.2015, o godz. 14:47:
For example:
if a > 0 {
….
} else a < -5 {
…
}This would be the same as:
if a > 0 {
….
} else {
precondition(a < -5)
…
}
My first thought was that at first glance I'd get this confused with "else if". Obviously that doesn't change semantics in correct code, but it does seem a little subtle.
My second thought was "precondition or assert?" (i.e. "is the check enabled in release builds?") and that convinced me that this wasn't really worth the added complexity. It's a neat idea, but I think the language becomes more complex because of it without sufficient gain.
I think “assert" should be removed from the language.
On Dec 8, 2015, at 6:34 PM, Jordan Rose <jordan_rose@apple.com> wrote:
Jordan
On Dec 8, 2015, at 5:47, Amir Michail via swift-evolution <swift-evolution@swift.org> wrote:
For example:
if a > 0 {
….
} else a < -5 {
…
}This would be the same as:
if a > 0 {
….
} else {
precondition(a < -5)
…
}_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution