[swift-evolution] What about garbage collection?

Vanderlei Martinelli vmartinelli at alecrim.com
Mon Feb 8 23:12:11 CST 2016


It is good to explain that in the example I gave we do not have to declare
self as weak (completion handlers do not need this), but it was declared
this way to not retain the view controller (or view) while the user is
already seeing something else on the screen.

-Van

On Tue, Feb 9, 2016 at 3:04 AM, Vanderlei Martinelli <
vmartinelli at alecrim.com> wrote:

> Particularly I think the strong/weak dance, after understood and properly
> applied, is a benefit and not a bad thing.
>
> We can write things like:
>
> doSomeLongRunningTaskThatCannotBeCancelled { [weak self] someText in
>     self?.someLabel.text = someText
> }
>
> This is a very common case in Cocoa [Touch], I think. Using GC how could
> we say: “hey, if the result comes in and I'm no longer here, just ignore
> it, okay?”
>
> I really like that RC and ARC are alive in Swift. Perhaps in the future we
> have something better, yet I would still like to be able to write code like
> the above. About GC: I do not know any good reasons to bring it to Swift.
>
> -Van
>
> On Tue, Feb 9, 2016 at 2:54 AM, Paul Ossenbruggen via swift-evolution <
> swift-evolution at swift.org> wrote:
>
>>
>> On Feb 8, 2016, at 1:00 PM, Chris Lattner via swift-evolution <
>> swift-evolution at swift.org> wrote:
>>
>>
>>    -
>>    the closure capture syntax uses up an unreasonable amount of
>>    mindshare just because of [weak self]
>>
>>
>> I think that this specific point is solvable in others ways, but I’ll
>> interpret this bullet as saying that you don’t want to worry about
>> weak/unowned pointers.  I completely agree that we strive to provide a
>> simple programming model, and I can see how "not having to think about
>> memory management" seems appealing.
>>
>> I actually like RC, and don’t find it particularly problematic except in
>> this one case…the closure case. If we could solve this one problem then I
>> think the rest of it is fine. I don’t mind remembering to put a weak
>> reference in for back pointers etc. The benefits of RC are great, and the
>> introduction of ARC was a great mental burden lifted of developer’s minds.
>> Just trying to explain and remember all the tricky rules around the closure
>> capture would be nice to solve and would love to discuss that rather than
>> garbage collection.
>>
>> - Paul
>>
>>
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160209/f382c3e7/attachment.html>


More information about the swift-evolution mailing list