@noescape


(Nate Birkholz) #1

I understand how @noescape works, and some of its benefits, I *think*, but
if I am correct, it almost seems like it should be added automatically to
my closure definitions until it becomes clear that the closure has to
escape its context, much like I tend to declare variables as `let` until it
becomes clear I need a `var`.

How much are people using @noescape? I'm working on making recommendations
at work on how to make our codebase more idiomatic Swift, but this one
escapes me (har!).

Sorry for the open-ended question, by the way, but this seems like the
better venue fo0r it than others I might try.

···

--
Nate Birkholz


(Jens Alfke) #2

IIRC, there is a current proposal to change the language in exactly that way — i.e. to have noescape be the default and use an attribute like “@escapes” to declare that a closure can be stored by the callee and called later.

—Jens

···

On May 16, 2016, at 9:37 AM, Nate Birkholz via swift-users <swift-users@swift.org> wrote:

I understand how @noescape works, and some of its benefits, I *think*, but if I am correct, it almost seems like it should be added automatically to my closure definitions until it becomes clear that the closure has to escape its context, much like I tend to declare variables as `let` until it becomes clear I need a `var`.


(Nate Birkholz) #3

Well that was where I was going next, heh.

···

On Mon, May 16, 2016 at 9:41 AM, Jens Alfke <jens@mooseyard.com> wrote:

On May 16, 2016, at 9:37 AM, Nate Birkholz via swift-users < > swift-users@swift.org> wrote:

I understand how @noescape works, and some of its benefits, I *think*, but
if I am correct, it almost seems like it should be added automatically to
my closure definitions until it becomes clear that the closure has to
escape its context, much like I tend to declare variables as `let` until it
becomes clear I need a `var`.

IIRC, there is a current proposal to change the language in exactly that
way — i.e. to have noescape be the default and use an attribute like
@escapes” to declare that a closure can be stored by the callee and called
later.

—Jens

--
Nate Birkholz


(Adriano Ferreira) #4

Here’s the related thread https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151214/003748.html

Cheers,

— A

···

On May 16, 2016, at 12:43 PM, Nate Birkholz via swift-users <swift-users@swift.org> wrote:

Well that was where I was going next, heh.

On Mon, May 16, 2016 at 9:41 AM, Jens Alfke <jens@mooseyard.com <mailto:jens@mooseyard.com>> wrote:

On May 16, 2016, at 9:37 AM, Nate Birkholz via swift-users <swift-users@swift.org <mailto:swift-users@swift.org>> wrote:

I understand how @noescape works, and some of its benefits, I *think*, but if I am correct, it almost seems like it should be added automatically to my closure definitions until it becomes clear that the closure has to escape its context, much like I tend to declare variables as `let` until it becomes clear I need a `var`.

IIRC, there is a current proposal to change the language in exactly that way — i.e. to have noescape be the default and use an attribute like “@escapes” to declare that a closure can be stored by the callee and called later.

—Jens

--
Nate Birkholz
_______________________________________________
swift-users mailing list
swift-users@swift.org <mailto:swift-users@swift.org>
https://lists.swift.org/mailman/listinfo/swift-users


(Adriano Ferreira) #5

Nate,

Let me know if you’d like some help to write a draft/proposal. I’d be happy to help :stuck_out_tongue:

Best,

— A

···

On May 17, 2016, at 3:04 PM, Adriano Ferreira via swift-users <swift-users@swift.org> wrote:

Here’s the related thread https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151214/003748.html

Cheers,

— A

On May 16, 2016, at 12:43 PM, Nate Birkholz via swift-users <swift-users@swift.org <mailto:swift-users@swift.org>> wrote:

Well that was where I was going next, heh.

On Mon, May 16, 2016 at 9:41 AM, Jens Alfke <jens@mooseyard.com <mailto:jens@mooseyard.com>> wrote:

On May 16, 2016, at 9:37 AM, Nate Birkholz via swift-users <swift-users@swift.org <mailto:swift-users@swift.org>> wrote:

I understand how @noescape works, and some of its benefits, I *think*, but if I am correct, it almost seems like it should be added automatically to my closure definitions until it becomes clear that the closure has to escape its context, much like I tend to declare variables as `let` until it becomes clear I need a `var`.

IIRC, there is a current proposal to change the language in exactly that way — i.e. to have noescape be the default and use an attribute like “@escapes” to declare that a closure can be stored by the callee and called later.

—Jens

--
Nate Birkholz
_______________________________________________
swift-users mailing list
swift-users@swift.org <mailto:swift-users@swift.org>
https://lists.swift.org/mailman/listinfo/swift-users

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


(Nate Birkholz) #6

I saw elsewhere (In Chris Lattner's thread about ABI) that they are already
considering it as part of the base proposal, can anyone from the Swift team
confirm whether we need an official separate proposal?

···

On Tue, May 17, 2016 at 12:08 PM, Adriano Ferreira <adriano.ferreira@me.com> wrote:

Nate,

Let me know if you’d like some help to write a draft/proposal. I’d be
happy to help :stuck_out_tongue:

Best,

— A

On May 17, 2016, at 3:04 PM, Adriano Ferreira via swift-users < > swift-users@swift.org> wrote:

Here’s the related thread
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151214/003748.html

Cheers,

— A

On May 16, 2016, at 12:43 PM, Nate Birkholz via swift-users < > swift-users@swift.org> wrote:

Well that was where I was going next, heh.

On Mon, May 16, 2016 at 9:41 AM, Jens Alfke <jens@mooseyard.com> wrote:

On May 16, 2016, at 9:37 AM, Nate Birkholz via swift-users < >> swift-users@swift.org> wrote:

I understand how @noescape works, and some of its benefits, I *think*,
but if I am correct, it almost seems like it should be added automatically
to my closure definitions until it becomes clear that the closure has to
escape its context, much like I tend to declare variables as `let` until it
becomes clear I need a `var`.

IIRC, there is a current proposal to change the language in exactly that
way — i.e. to have noescape be the default and use an attribute like
@escapes” to declare that a closure can be stored by the callee and called
later.

—Jens

--
Nate Birkholz
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

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

--
Nate Birkholz