SE-0532: Optional noncopyable improvements and generalizations

Hello, Swift community.

The LSG met to discuss this proposal. Feedback has generally been positive. I'd like to discuss three issues raised during the review.

The first issue is about the naming of the insert operation, which is essentially just the ordinary assignment operator (=) but taking a non-optional Wrapped and returning a MutableRef<Wrapped>. Feedback suggests that insert is not a great name for this, and the LSG agrees. We note several possible names for this:

  • insert (as previously proposed, which comes from Rust, but which the author has wavered on)
  • put (currently favored by the author)
  • assign (suggested earlier in the review thread)
  • update (has some precedent in the Swift standard library, e.g. on the UnsafePointer types)

The author has chosen to propose put as the new name for this operation. The LSG considers this an open question and welcomes feedback on any of these alternatives.

The second is about the inclusion of the borrow() and mutate() functions, which one could consider to be accessors for the payload of the some case. The LSG has previously indicated that it is reluctant to add general features around case accessors without a broader vision for these kinds of ad hoc pattern-matching-adjacent features in Swift. However, the LSG sees Optional as a special case and has no concerns about adding narrowly-tailored features around it.

The third is specifically about the naming of borrow() and mutate(). The LSG sees these as analogous to span and mutableSpan and believes they ought to be properties. We have asked the author to name these properties ref and mutableRef.

The LSG has decided to accept SE-0532 in principle but is extending the review until July 6th to discuss the naming of (1) the put operation and (2) the ref and mutableRef properties. You can see the exact changes made in this revision here.

John McCall
Review Manager

9 Likes