[swift-evolution] Default lazy constructor

Félix Cloutier felixcca at yahoo.ca
Tue Jan 5 11:25:23 CST 2016


Have you heard of the property behaviors proposal?

Félix

> Le 5 janv. 2016 à 08:48:03, James Campbell via swift-evolution <swift-evolution at swift.org> a écrit :
> 
> When creating a lazy variable, maybe we should allow for default closures, i.e
> 
> lazy var userSession: UserSession
> 
> Which will construct that object for you
> instead of having to do:
> 
> lazy var object: MyObject {
>         let userSession = UserSession()
> 
>         return userSession
> 
> }()
> 
> If the initializer requires parameter values then as an extension of this we could pass them in psuedo C++ style:
> 
> lazy var object: UserSession(otherVariable) 
> 
> Potentially otherVariable in this case could be lazily processed, so that its the equivalent of:
> 
> 
> lazy var object: MyObject {
>         let userSession = UserSession(otherVariable)
> 
>         return userSession
> 
> }()
> 
> 
> -- 
>  Wizard
> james at supmenow.com <mailto:james at supmenow.com>
> +44 7523 279 698
>  _______________________________________________
> 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/20160105/c8cd46b0/attachment.html>


More information about the swift-evolution mailing list