> On Feb 6, 2017, at 10:02 AM, Jordan Rose via swift-dev <swift-dev@swift.org> 
> wrote:
> 
> I’ve said this Michael in person, but I’ll put it on the thread for others to 
> see:
> 
> I don’t think modeling this is worth the increase in complexity. There’s a 
> partial workaround for anyone who notices this being a problem, which is to 
> put any expensive work in a ‘do’ block. And actually emitting cleanups before 
> a call to, e.g., dispatch_main would be a change in semantics, which could 
> both break existing programs and makes the language a bit harder to reason 
> about. The current rule that “defers happen at the close brace, releases may 
> happen sooner” is simple. (We certainly would not want to make ‘defer’s 
> happen before calling dispatch_main, though perhaps we should warn that they 
> will never be executed.)

And we should keep that rule. The optimizer can't move `defer`s no matter what, 
since they're semantically fixed to happen at end of scope, so they would 
always "leak" in a case like `defer { doSomething() }; abort()`. It's only 
value lifetimes that could be shortened, and shortening lifetimes before a 
noreturn call wouldn't be a change to the existing model.

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

Reply via email to