[swift-evolution] [Proposal] Property behaviors

davesweeris at mac.com davesweeris at mac.com
Thu Jan 14 19:16:03 CST 2016

In favor of them being just functions (even if they were declared as part of a class/struct/whatever)…

Isn’t there a proposal for a function composition operator floating around? I think it was “•” (option-8)… Anyway, assume that’s what I mean by “•”.
var <lazy•resettable•changeObserved> foo: Int = {…}

Plus, it’d make the order in which they were applied obvious.

Actually, speaking of using functions that were declared as part of an object… Could this all be done now by introducing an Observable<T> struct which itself uses the existing will/didSet functions? Like this? 	
var foo = Observable(3, lazy•resettable•changeObserved)

I think the only thing off the top of my head that wouldn’t pretty much Just Work is automatically converting between Observable<T> and T, the way you can with Implicitly Unwrapped Optionals. I might play with it a bit tonight after dinner.

- Dave Sweeris

> On Jan 14, 2016, at 14:05, Joe Groff via swift-evolution <swift-evolution at swift.org> wrote:
> If behaviors have dedicated declarations instead of being applications of plain types or functions, it also becomes more reasonable to let them be used as attributes by themselves
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160114/085f63d4/attachment.html>

More information about the swift-evolution mailing list