[swift-evolution] Pitch: Deinit for structs

2015-12-23 Thread Charles Srstka via swift-evolution
Introduction: This is a rather simple proposal, requesting that structs allow the ‘deinit’ destructor, as classes currently do. Motivation: Sometimes it is necessary to create an object that wraps a network connection (that needs to be closed when the object is destroyed), or that writes to a

Re: [swift-evolution] Pitch: Deinit for structs

2015-12-23 Thread Joe Groff via swift-evolution
> On Dec 23, 2015, at 1:07 PM, Charles Srstka via swift-evolution > wrote: > > Introduction: > > This is a rather simple proposal, requesting that structs allow the ‘deinit’ > destructor, as classes currently do. > > Motivation: > > Sometimes it is necessary to

Re: [swift-evolution] Pitch: Deinit for structs

2015-12-23 Thread Félix Cloutier via swift-evolution
Just chiming in with you two: deinit for a struct doesn't really work because structs are copied and destroyed all the time. Putting a file descriptor in a struct (along with destruction logic) would fail pretty hard without C++-like copy/move semantics. Félix > Le 23 déc. 2015 à 16:21:42,

Re: [swift-evolution] Pitch: Deinit for structs

2015-12-23 Thread Matthew Johnson via swift-evolution
Sent from my iPad > On Dec 23, 2015, at 3:15 PM, Joe Groff via swift-evolution > wrote: > > >> On Dec 23, 2015, at 1:07 PM, Charles Srstka via swift-evolution >> wrote: >> >> Introduction: >> >> This is a rather simple proposal,

Re: [swift-evolution] Pitch: Deinit for structs

2015-12-23 Thread Matthew Johnson via swift-evolution
> On Dec 23, 2015, at 5:25 PM, Joe Groff wrote: > >> >> On Dec 23, 2015, at 3:16 PM, Matthew Johnson > > wrote: >> >> >> >> Sent from my iPad >> >>> On Dec 23, 2015, at 3:15 PM, Joe Groff via swift-evolution >>>

Re: [swift-evolution] Pitch: Deinit for structs

2015-12-23 Thread David Owens II via swift-evolution
This is something I asked for before, then I realized it wouldn’t work. func helper(rs: ResourceHandle) {} let resource = ResourceHandle() helper(resource) result.doSomething() // error Another example: let x = Handle() do { let y = x } // resources are freed here as deinit is called // x