Finalizers aren't free, but every handle already has a finalizer, so that's not an extra cost.

On Wed, Dec 30, 2020, 2:50 PM Oleg Grenrus <oleg.grenrus@iki.fi> wrote:
I would be afraid of making this change. File descriptors are a scarce
resource, and relying on non-deterministic GC behavior to free them is
big -1.

Also finalizers are not free in current GC. (Though, you probably cannot
won't that many open files that it would matter).

- Oleg

On 30.12.2020 21.23, David Feuer wrote:
> withFile keeps the handle it creates alive until the user action
> completes. If we want to avoid this, we can. All that's required is to
> capture the weak reference that holds the handle's finalizer. Then
> instead of closing the handle in the end (or on exception) using
> hClose, withFile can run the handle's finalizer. Should we do this? Or
> does it run too much against the idea that handles should be managed
> as explicitly as possible?
>
> _______________________________________________
> Libraries mailing list
> Libraries@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
Libraries@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries