[swift-evolution] [Review] SE-0024 "Optional Value Setter `??=`"

Brent Royal-Gordon brent at architechies.com
Sat Feb 13 15:48:01 CST 2016

> 	• What is your evaluation of the proposal?

A soft +1.

I am worried about the attractive nuisance quality of this proposal; users may be tempted to leave variables optional and mutable even though they could be non-optional constants. But there are good, solid use cases for it, like working with properties or subscripts that are always optional, and I think this will be genuinely useful there.

A warning with a fix-it *might* be warranted when this operator is used with a local variable that is not mutated again later in the function, but that could be overkill.

> 	• Is the problem being addressed significant enough to warrant a change to Swift?

It's a minor problem. If the proposed solution did some sort of serious violence to the language, I might say it's not significant. But this is a purely additive change that has no impact on the rest of the language, so I would say the problem is significant enough to warrant such a low-impact solution.

> 	• Does this proposal fit well with the feel and direction of Swift?

Yes. It flows naturally from other patterns in our operators.

> 	• If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?

I implemented the Perl 5 version of this operator, `//=`. Perl's looser typing (any value can be `undef`) made it more useful there, but that doesn't mean it won't be useful in Swift too.

> 	• How much effort did you put into your review? A glance, a quick reading, or an in-depth study?

I read the proposal and the rest of this thread, and of course as previously mentioned I have some experience in these matters.

Brent Royal-Gordon

More information about the swift-evolution mailing list