[swift-evolution] [Review] SE-0030 Property Behaviors

Tino Heth 2th at gmx.de
Mon Feb 22 05:52:33 CST 2016

I'm still very torn on this proposal, and I think a final evaluation should take into account the long-term goal of "hygienic macros":
Right now, I haven't seen anything concrete on this topic, as it is somewhat out of scope now — but there are soaring dreams for meta programming in Swift, and behaviors could be solved that way as well.

It is common practice to ask the question "would we add this feature now if we didn't already have it?" when it is about deprecating elements of the language; I fear that property behaviors might become to important to be removed once they are integrated, so I'm asking myself:
Would I add this feature if I could do something like

#Self.addProperty("age", type: Int, behavior: Lazy { return Date().year - self.birthday.year })

(this all is highly speculative, and so is the syntax — but I hope the intention is of that line is clear)

As the evolution process favors small steps, it is somewhat unfair to challenge a proposal this way, but imho sometimes it is important to step back and consider the "big picture" — which, btw, may as well lead to the conclusion that macros shouldn't be able to add behaviors, or that the feature deserves a special syntax anyways...

- Tino

More information about the swift-evolution mailing list