From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id BAA20261; Thu, 13 Nov 2003 01:51:25 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id BAA19826 for ; Thu, 13 Nov 2003 01:51:24 +0100 (MET) Received: from bob.west.spy.net (mail.west.spy.net [66.149.231.226]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id hAD0pG128160 for ; Thu, 13 Nov 2003 01:51:20 +0100 (MET) Received: from [10.9.254.240] (sjc-dist3-e3.2wire.com [63.203.253.2]) by bob.west.spy.net (Postfix) with ESMTP id 115016772 for ; Wed, 12 Nov 2003 16:50:50 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v606) Content-Transfer-Encoding: 7bit Message-Id: <6CF992BC-1573-11D8-A660-000393CFE6B8@spy.net> Content-Type: text/plain; charset=US-ASCII; format=flowed To: Caml Mailing List From: Dustin Sallings Subject: [Caml-list] GC and file descriptors Date: Wed, 12 Nov 2003 16:50:50 -0800 X-Mailer: Apple Mail (2.606) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; descriptors:01 buf:01 buf:01 unix:02 unix:02 string:03 string:03 let:04 let:04 len:05 len:05 structures:05 somewhat:06 type:07 written:08 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I keep ending up with somewhat awkward structures to close files I've opened. Does the GC take care of any of this type of thing? I.e., could the following: let tput x = let r = Unix.open_process_in ("tput " ^ x) and buf = String.create 8 in let len = input r buf 0 8 in close_in r; String.sub buf 0 len ;; be written like this: let tput x = let buf = String.create 8 in String.sub buf 0 (input (Unix.open_process_in ("tput " ^ x)) buf 0 8) ;; safely? -- Dustin Sallings ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners