Is "lazy let" on the schedule anywhere?


(Edward Connell) #1

It sure would be nice if the compiler supported lazy lets for structs. Any
idea when or if this will be supported?

Seems like a nice performance win, lazy var is a pain because you can't
access arguments passed into a function without mutation complaints.

Thanks, Ed


(Slava Pestov) #2

If you’re not passing the value type as an inout, how will the ‘lazy let’ property write back the new value?

Slava

···

On Jun 26, 2017, at 3:32 PM, Edward Connell via swift-users <swift-users@swift.org> wrote:

It sure would be nice if the compiler supported lazy lets for structs. Any idea when or if this will be supported?

Seems like a nice performance win, lazy var is a pain because you can't access arguments passed into a function without mutation complaints.

Thanks, Ed
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(Adrian Zubarev) #3

I myself highly want lazy constants (I’m tired of writing something like file private private(set) lazy var propertyName: ReferenceType just to hide the setter from the rest of the codebase), but I don’t think this will ever happen in Swift, at least not as an improvement for the lazy keyword itself. Joe Groff had a really awesome proposal last year, which is currently in a deferred state but will be resurrected in the future.

https://github.com/apple/swift-evolution/blob/master/proposals/0030-property-behavior-decls.md

It’s simply is a prioritization question, when this will happen.

That said, I’d expect some kind of readOnlyLazy property behavior that will match the mentioned lazy let.

···

--
Adrian Zubarev
Sent with Airmail

Am 26. Juni 2017 um 21:32:35, Edward Connell via swift-users (swift-users@swift.org) schrieb:

It sure would be nice if the compiler supported lazy lets for structs. Any idea when or if this will be supported?

Seems like a nice performance win, lazy var is a pain because you can't access arguments passed into a function without mutation complaints.

Thanks, Ed
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users