Re: [swift-users] Re-initializing lazy vars

2017-10-21 Thread Joanna Carter via swift-users
Oops! forgot to add example code for resetting with non-optional public var : public struct TestStruct { private var _description: String? public var description: String { get { return _description ?? "" } set { _description = newValue } }

Re: [swift-users] Re-initializing lazy vars

2017-10-21 Thread Joanna Carter via swift-users
> It just seems so obvious to create-if-nil, and makes it nice to reset stuff > that should be re-created. In my case, after my NSURLSession gets > invalidated, I wanted to set the property to nil, and next time a session was > needed, it would just get created. The only thing I would query

Re: [swift-users] Re-initializing lazy vars

2017-10-20 Thread Rick Mann via swift-users
It just seems so obvious to create-if-nil, and makes it nice to reset stuff that should be re-created. In my case, after my NSURLSession gets invalidated, I wanted to set the property to nil, and next time a session was needed, it would just get created. Sure, I can implement this myself, but

Re: [swift-users] Re-initializing lazy vars

2017-10-20 Thread Jordan Rose via swift-users
It's not directly related to property behaviors. It was a bug that only worked with ImplicitlyUnwrappedOptional properties; we patched the type checker bug that led to it being allowed and didn't even notice until someone brought it up (SR-5172 ). It

Re: [swift-users] Re-initializing lazy vars

2017-10-19 Thread David Sweeris via swift-users
I don't know. IIRC (big if), though, there was talk of adding support for "property behaviors"(?). Resetting lazy vars probably would've been one of them, and if so, it probably got pulled so that we wouldn't risk breaking source compatibility later by adding a consistent syntax for other