[swift-evolution] [Rejected] SE-0024 Optional Value Setter ??=

Douglas Gregor dgregor at apple.com
Mon Feb 22 23:55:43 CST 2016


The review of SE-0024 "Optional Value Setter ??=“ ran from February 12...18, 2016. The proposal text is here:

	https://github.com/apple/swift-evolution/blob/master/proposals/0024-optional-value-setter.md

The proposal is rejected. While the ‘??=‘ operator’s semantics are clear and fit with other compound assignment operators, the use cases are not strong enough to motivate inclusion of this operator. Radek’s lukewarm +0.5 review <http://thread.gmane.org/gmane.comp.lang.swift.evolution/6895> captures the sentiment of the core team fairly well (as was echoed by others): one very common use case in the Ruby’s similar ||= operator is to assign a default value to an optional parameter or a local variable. However, neither case works well in Swift because ??= does not erase the optionality of the variable (and cannot be used to change a parameter now that var has been removed from parameters). Property access and subscripting could still benefit from ??=, but the latter case is likely to be handled better by a Dictionary subscript operator that can substitute a default value (see, e.g., Joe Groff’s suggestion <http://thread.gmane.org/gmane.comp.lang.swift.evolution/6895>).

	Doug Gregor
	Review Manager

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160222/48f04d15/attachment.html>


More information about the swift-evolution mailing list