[swift-evolution] [Proposal] Property behaviors

Joe Groff jgroff at apple.com
Thu Jan 14 12:33:53 CST 2016


Good catch, thanks!
> On Jan 14, 2016, at 9:49 AM, Ben Langmuir <blangmuir at apple.com> wrote:
> 
> Hey Joe,
> 
> Just a small bug report:
> A deferred initializer is used only after the initialization of the behavior's state. A deferred initializer cannot be referenced until the behavior's storage is initialized. A property using the behavior can refer to self within its initializer expression, as one would expect a lazy property to be able to.
> 
>   var behavior deferredInit: Int {
>     eager initializer: Int
> Presumably “eager” should be “deferred” here.
> 
> 
>> On Jan 13, 2016, at 2:07 PM, Joe Groff via swift-evolution <swift-evolution at swift.org <mailto: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:
>> 
>> https://gist.github.com/jckarter/50b838e7f036fe85eaa3 <https://gist.github.com/jckarter/50b838e7f036fe85eaa3>
>> 
>> For reference, here's the previous iteration:
>> 
>> https://gist.github.com/jckarter/f3d392cf183c6b2b2ac3
>> 
>> Thanks for taking a look!
>> 
>> -Joe
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160114/bbc82578/attachment.html>


More information about the swift-evolution mailing list