[swift-evolution] [Review] SE-0023 API Design Guidelines (when to use properties)

David Waite david at alkaline-solutions.com
Wed Jan 27 15:15:04 CST 2016


> On Jan 27, 2016, at 1:56 PM, Howard Lovatt <howard.lovatt at gmail.com> wrote:
> 
> I would say that if it doesn't have arguments and doesn't mutate then it should be a property, since it will read better and is flexible (you can switch between a stored and calculated property without affecting the external interface easily).

It can mutate as long as the mutation is not externally visible on that interface. An example of this would be if the implementation of Set were internally backed by a Splay Tree, where balancing of the tree happens on every access.

https://en.wikipedia.org/wiki/Splay_tree

Another example is any computed property ever which output logging.

-DW



More information about the swift-evolution mailing list