[swift-evolution] SE-0030 Property Behaviors

Taras Zakharko taras.zakharko at uzh.ch
Sun Feb 14 02:40:21 CST 2016

Ah, yes, sorry, should have double checked with the initial text before sending the message. For some reason I though that the accessor requirement declarations were limited to get/set. But I think that my basic point still holds. E.g. in Joe’s proposal, I don’t really see how lazy behaviour is achieved: the sample implementation for lazy he proposes seems to force evaluation of the initial value at the declaration time. Unless we have some sort of magic that wraps the initial value into a closure (but that is then the same as what Anton suggests, albeit explicitly). 

> On 14 Feb 2016, at 09:19, Brent Royal-Gordon <brent at architechies.com> wrote:
>> 1. Allow behaviours to specify abstract members that need to be implemented (akin to protocols) and get the initial value of lazy from there, e.g.:
>>    var lazy x : T {
>> 	func load() {
>> 		return 33
>> 	}
>>    }
>>  Pros: clean and clear. Cons: verbosity.
> The existing proposal's accessor feature does this. (The syntax would just be `load {}`, not `func load() {}`, though.)
> -- 
> Brent Royal-Gordon
> Architechies

More information about the swift-evolution mailing list