[swift-evolution] Required Callback

James Campbell james at supmenow.com
Wed Aug 17 09:10:41 CDT 2016

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*

*james at supmenow.com <james at supmenow.com>⎥supmenow.com <http://supmenow.com>*


*Runway East *

*10 Finsbury Square*


* EC2A 1AF *

On 17 August 2016 at 13:43, Brent Royal-Gordon <brent at architechies.com>

> > On Aug 16, 2016, at 12:44 PM, James Campbell via swift-evolution <
> swift-evolution at swift.org> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160817/853d3b93/attachment.html>

More information about the swift-evolution mailing list