Most of the cases I can think of for @required are for clean up mechanisms triggered by the closure and as such would only need to be called once.
So in theory @once may be able to cover this case, in a sense I guess you could argue @once is just a subset of @required it would check it is exactly once. But @required is about making sure it is called at all. *___________________________________* *James⎥Lead Hustler* *[email protected] <[email protected]>⎥supmenow.com <http://supmenow.com>* *Sup* *Runway East * *10 Finsbury Square* *London* * EC2A 1AF * On 17 August 2016 at 13:43, Brent Royal-Gordon <[email protected]> wrote: > > On Aug 16, 2016, at 12:44 PM, James Campbell via swift-evolution < > [email protected]> wrote: > > > > That sounds fair, the closure that function returns could trigger a > runtime warning when it detects the closure has be deallocated without > being triggered (or even mutliple times but ofc not the focus for this > proposal) > > You know, I'm thinking about that "multiple times" thing... > > We know we want a @once (formerly @noescape(once)) for closures which are > guaranteed to be called exactly once. This would help us with initializing > variables, and especially properties, from a closure. Perhaps we should > extend that to support @escaping @once. Would that handle these use cases? > Are there use cases for @required where you expect more than one call? I > think all of the use cases we've discussed here—ending handlers and > such—should only be called once. > > -- > Brent Royal-Gordon > Architechies > >
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
