[swift-evolution] SE-0030 Property behaviours

Антон Жилин antonyzhilin at gmail.com
Thu Feb 25 16:41:57 CST 2016

var behaviour computed<Value>: Value {
    accessor get() -> Value
    accessor set(newValue: Value) {
    get {
        return get()
    set {

There seems to be no way we can disable `set` if `accessor set` is
defaulted, based on current property behaviour rules. We could add both
@computed and @computedReadOnly, for example.

Behaviors already support read-only getters—you just omit the set {} block.

And I've just discovered a gaping hole in this design: mutability of
`accessor get` cannot be automatically forwarded to `get`. We would have to
always declare mutable `get`. Or have @computed, @computedMutable,
@computedReadOnly, @computedMutableReadOnly.

So computed properties should remain untouched for now, I guess.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160226/52400868/attachment.html>

More information about the swift-evolution mailing list