[swift-evolution] [Proposal] Property behaviors
me at tal.by
Wed Jan 13 16:37:18 CST 2016
For var [lazy] foo = 1738 how does the user or compiler know that foo, even
though it’s an Int, it has a property called `lazy` on it. And what happens
if that object type has a property named `lazy` already?
On Wed, Jan 13, 2016 at 5:07 PM, Joe Groff via swift-evolution <
swift-evolution at swift.org> wrote:
> Thanks everyone for the first round of feedback on my behaviors proposal.
> I've revised it with the following changes:
> - Instead of relying on mapping behaviors to function or type member
> lookup, I've introduced a new purpose-built 'var behavior' declaration,
> which declares the accessor and initializer requirements and provides the
> storage and behavior methods of the property. I think this gives a clearer
> design for authoring behaviors, and allows for a more efficient and
> flexible implementation model.
> - I've backed off from trying to include 'let' behaviors. As many of you
> noted, it's better to tackle immutable computed properties more
> holistically than to try to backdoor them in.
> - I suggest changing the declaration syntax to use a behavior to square
> brackets—'var [behavior] foo'—which avoids ambiguity with destructuring
> 'var' bindings, and also works with future candidates for behavior
> decoration, particularly `subscript`.
> Here's the revised proposal:
> For reference, here's the previous iteration:
> Thanks for taking a look!
> swift-evolution mailing list
> swift-evolution at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution