[swift-evolution] An upcoming proposal for simplifying leak free, safe closures.
admin at wheerd.de
Mon Jun 27 03:45:09 CDT 2016
On 06/26/2016 09:10 PM, Christopher Kornher via swift-evolution wrote:
> The core proposal:
> Closures capturing object references should automatically capture all
> object references as weak.
In my code, most closures are used in a functional programming capacity,
e.g. with map(), reduce, etc. Hence, most closures are non-escaping and
local, where strong capture is the desired way. Otherwise I would have
to litter everything with optional unwrapping or add the explicit
capture definition which would both make the code less readable in my
> 1) Closures with object references could be simplified further by
> implicitly including ‘let’ guards for all object references:
This sounds good for closures without return value, but how would you
handle closures with non-optional non-void return values?
Also I think that explicit error handling in case of "expired" objects
is safer than silent failure (by not executing the closure).
Kind regards, Manuel
More information about the swift-evolution