Re: [swift-evolution] [Proposal] A more liberal placement of defer

2016-06-06 Thread donny wals via swift-evolution
tics of the `defer` > statement, and I don't see any advantage. Sorry. > > -Michael > >> Am 06.06.2016 um 22:14 schrieb donny wals via swift-evolution >> <swift-evolution@swift.org>: >> >> Michael, >> >> How would this proposal break your snip

Re: [swift-evolution] [Proposal] A more liberal placement of defer

2016-06-06 Thread donny wals via swift-evolution
ditions have been met.: > > guard something > guard something > allocate memory; defer {release memory} > > -- E > > > >> On Jun 6, 2016, at 1:50 PM, donny wals via swift-evolution >> <swift-evolution@swift.org> wrote: >> >> Hi, >&

Re: [swift-evolution] [Proposal] A more liberal placement of defer

2016-06-06 Thread donny wals via swift-evolution
s its purpose. And simple functions like fibonacci I would just write > without using `defer` at all - it's just confusing to use `defer` and `inout` > in this case IMO. > > /// Calculates the n'th fibonacci number. (n >= 1) > func fibonacci(n: Int) -> Int { >var a =

[swift-evolution] [Proposal] A more liberal placement of defer

2016-06-06 Thread donny wals via swift-evolution
Hi, When we’re using defer we write some code that we want to execute the moment a scope exits. This leads to code that could read like: let fibonacci = sequence(state: (0, 1)) { (pair: inout (Int, Int)) -> Int in defer { pair = (pair.1, pair.0 + pair.1) } return pair.0 } What I find