I often support convenience features. I like it when the code we write every day gets more and more fluid.
But we're talking about control flow, not about the standard library: the proposal changes the fabric of the language.
I'm questioning the underlying motivation, and I'm afraid the proposal is just trying to take Swift further apart from other languages, without much rationale.
Is the problem being addressed significant enough to warrant a change to Swift?
No. The code below has no problem:
if let sequence = sequence {
for element in sequence {
...
}
}
Does this proposal fit well with the feel and direction of Swift?
Let's look at this table of control flow keywords, below:
keyword | keyword? | keyword! |
---|---|---|
try | try? | try! |
while | ||
if | ||
for | for? | |
switch | ||
return |
I guess switch?
would turn missing after this proposal is implemented. Do we want it?
And return?
looks actually quite handy:
var firstName: String?
var lastName: String?
func anyName() -> String? {
return? firstName
return? lastName
return nil // could be omitted if return? were **super** handy
}
So. Are we planning something?