[swift-evolution] [Proposal] Property behaviors

Berik Visschers berik at visschers.nu
Thu Dec 17 18:46:58 CST 2015

Property behaviors would allow for much more then two-phase init and flexibility on lazy. Libraries (standard or custom) would gain declarative ways of providing deep integration in other types; And, although that can be really cool, it also worries me. I'll exaggerate to make a point:

person.name = "Berik" // animates a UILabel update, updates a database record, sends an HTTP PUT, and, oh right; it does not update the name property. 

This kind of side effects are possible with dynamic setters already, but property behaviors allow them to become more common. The fact that swift code generally has few side affects is a great feature. I'm basically asking for careful consideration. 

Allowing "let" properties to be dynamic seems counter intuitive to me. On the one hand, using "var" for a two-phase initialized constant property is ugly, but allowing "let" variables to change over time seems too much of a sacrifice of consistency.  


More information about the swift-evolution mailing list