I wonder what these significant tradeoffs are? if/else and switch not being expressions makes certain code really awkward to write. Luckily Swift doesn't force you to use mutability here, but it's still weird IMO.
I wonder what these significant tradeoffs are? if/else and switch not being expressions makes certain code really awkward to write. Luckily Swift doesn't force you to use mutability here, but it's still weird IMO.
Exactly which statements should be included (certainly if and switch, any others)?
Further, it is important to consider whether the code written using this will actually be better than the code written with these things as statements. For example, the “switch” blocks tend to be very large, and turning them into expressions encourages additional indentation. Swift already allows ‘let’ values to be initialized on multiple paths, so is the win actually that great?
Given that statements-as-expressions would provide another way to do things (they are a purely syntax extension) the barrier should high to add them. They will add complexity and surface area to the language, so they need to pay that complexity.
[0] https://lists.swift.org/pipermail/swift-evolution/2015-Decem...
I would argue that allowing 'let' values to be initialized on multiple paths is uglier than having them be always initialized by exactly one expression. But, I see their point.