From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id 2CAA37ED1A for ; Mon, 21 May 2012 13:23:44 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: An4CAIIkuk+A1q1LnGdsb2JhbABEhS2uVyIBAQEBAQgLCQkUJ4I/gQsCJgKJAASeFI48kkeBJowOggqBFAOIPIxehT2NIA X-IronPort-AV: E=Sophos;i="4.75,631,1330902000"; d="scan'208";a="159155856" Received: from smtp-rs1-vallila2.fe.helsinki.fi ([128.214.173.75]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 21 May 2012 13:23:43 +0200 Received: from webmail.helsinki.fi (webmail1-vallila2.fe.helsinki.fi [128.214.173.135]) by smtp-rs1.it.helsinki.fi (8.14.4/8.14.4) with ESMTP id q4LBNaXL014808; Mon, 21 May 2012 14:23:36 +0300 Received: from xdsl-83-150-94-164.nebulazone.fi (xdsl-83-150-94-164.nebulazone.fi [83.150.94.164]) by webmail.helsinki.fi (Horde Framework) with HTTP; Mon, 21 May 2012 14:23:36 +0300 Message-ID: <20120521142336.79901oeoxunjuoc8.lealanko@webmail.helsinki.fi> Date: Mon, 21 May 2012 14:23:36 +0300 From: "Lauri Alanko" To: caml-list@inria.fr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; DelSp="Yes"; format="flowed" Content-Disposition: inline Content-Transfer-Encoding: 7bit User-Agent: Internet Messaging Program (IMP) 4.2.2 Subject: [Caml-list] Channels not closed on gc? I only recently noticed that ocaml does not close open channels when they are garbage collected. This is evidently intentional behavior, but it was quite unexpected. To be clear, I do think it's bad style to rely on GC for releasing OS resources, but that doesn't explain why GC shouldn't do this if the programmer has failed to explicitly close the channel. And if the intention were to _enforce_ good style, the channel finaliser would spout out an error or warning upon detecting that the channel hasn't yet been closed, instead of just silently leaking file handles like it does currently. It is of course trivial to "fix" this by attaching a simple finaliser, but the fact that this is not done by default makes me suspect that there would be something fishy with this approach. So, what's the rationale for the current behavior? Thanks, Lauri