[swift-evolution] [Review] SE-0024 "Optional Value Setter `??=`"
dsa.mls at icloud.com
Tue Feb 16 19:45:27 CST 2016
> Le 13 févr. 2016 à 00:15, Douglas Gregor via swift-evolution <swift-evolution at swift.org> a écrit :
> https://github.com/apple/swift-evolution/blob/master/proposals/0024-optional-value-setter.md <https://github.com/apple/swift-evolution/blob/master/proposals/0024-optional-value-setter.md>
> What is your evaluation of the proposal?
Fits among the other assignment operators. Contrary to some beliefs, the nil/optional coalescing operator can still return an optional:
strongOptional = strongOptional ?? weakOptional
So the ??= assignment is well suited (for the form resulting in optional):
strongOptional ??= weakOptional
It may not be the best option for dictionary as some pointed out, but it can be use outside dictionary as well, allowing one to break long chain of nil/optional coalescing.
strongOptional = strongOptional ?? weakOptional ?? weakerOptional ?? weakestOptional
In some possible used case:
currentSetting = currentSetting ?? userDefault ?? systemDefault ?? builtinDefault
currentSetting ??= userDefault
currentSetting ??= systemDefault
currentSetting ??= builtinDefault
> Is the problem being addressed significant enough to warrant a change to Swift?
Not really a problem, just a "why is this missing" state. The change also seem of minimal churn and be of low risk.
> Does this proposal fit well with the feel and direction of Swift?
It’s just an assignment operator among others which are similar in shape, its not evolution and as such have no direction.
> If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
> How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
Been following the thread
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution