someObject.callBack() { [weak self] in
if let me = self {
me.doSomething()
...
}
}
and friends (guard, etc) are pretty common. I'd love to have some sugar
for that - maybe "firm"
someObject.callBack() { [firm self] in
self.doSomething()
...
}
where firm guarantees that the named variable[s] won't be nil - if they
are, the block is skipped.
I think this would make the language easier to use (skipping the
complexities/distinction between weak/unowned), more concise, and generally
more pleasant.
Le 1 févr. 2016 à 18:40:18, Kurt Werle via swift-evolution <swift-evolution@swift.org> a écrit :
The pattern
someObject.callBack() { [weak self] in
if let me = self {
me.doSomething()
...
}
}
and friends (guard, etc) are pretty common. I'd love to have some sugar for that - maybe "firm"
someObject.callBack() { [firm self] in
self.doSomething()
...
}
where firm guarantees that the named variable[s] won't be nil - if they are, the block is skipped.
I think this would make the language easier to use (skipping the complexities/distinction between weak/unowned), more concise, and generally more pleasant.
The bind thread is certainly similar, and if something like that was
adapted, I'd like to see [bind self] do the same kind of thing in closure
declarations that I'm proposing [firm self] does - but the very odd
syntax for closure parameters tastes pretty different to me than a lot of
the rest of the language. I don't think it's unreasonable to discuss them
separately.
Thanks,
Kurt
···
On Tue, Feb 2, 2016 at 12:02 AM, Félix Cloutier <felixcca@yahoo.ca> wrote:
Le 1 févr. 2016 à 18:40:18, Kurt Werle via swift-evolution < > swift-evolution@swift.org> a écrit :
The pattern
someObject.callBack() { [weak self] in
if let me = self {
me.doSomething()
...
}
}
and friends (guard, etc) are pretty common. I'd love to have some sugar
for that - maybe "firm"
someObject.callBack() { [firm self] in
self.doSomething()
...
}
where firm guarantees that the named variable[s] won't be nil - if they
are, the block is skipped.
I think this would make the language easier to use (skipping the
complexities/distinction between weak/unowned), more concise, and generally
more pleasant.