[swift-evolution] Support for pure setters

Jessy Catterwaul mr.jessy at gmail.com
Thu Feb 4 09:25:14 CST 2016


My original post from yesterday, which describes the way that I am using set-only properties in Swift, still has not gotten through; attempting again:

I use set-only properties very, very often. I am interested to know how ubiquitous functions that begin with “set” are, in  frameworks. I’m currently under the impression that people usually don’t recognize that they could be using a setter, instead of a function, due to those frameworks, coming from a respected source, causing them to believe that the practice is reasonable.

/// Use this as the getter for set-only properties, 
/// until Swift has real set-only properties.
///- Important: Causes a fatal error, logging the name of the property.
///- Parameter propertyName: Never use this; only use the default.
@noreturn public func setOnlyPropertyGetterError(propertyName: String = __FUNCTION__) {
   fatalError("\(propertyName) is set-only")
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160204/e1af8fd1/attachment.html>


More information about the swift-evolution mailing list