From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 04521BB84 for ; Thu, 11 May 2006 02:09:16 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k4B09EoZ017242 for ; Thu, 11 May 2006 02:09:15 +0200 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 CAA28215 for ; Thu, 11 May 2006 02:09:14 +0200 (MET DST) Received: from lion.seas.upenn.edu (LION.SEAS.upenn.edu [158.130.12.194]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k4B09CXn017103 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 11 May 2006 02:09:13 +0200 Received: from [192.168.19.128] (cpe-68-174-95-226.ucwphilly.res.rr.com [68.174.95.226]) (authenticated bits=0) by lion.seas.upenn.edu (8.13.6/8.12.10) with ESMTP id k4B0923O019903 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 10 May 2006 20:09:12 -0400 Message-ID: <44628062.6010509@cis.upenn.edu> Date: Wed, 10 May 2006 20:08:02 -0400 From: Geoffrey Alan Washburn User-Agent: Thunderbird 1.5.0.2 (X11/20060420) MIME-Version: 1.0 Newsgroups: gmane.comp.lang.caml.inria To: brogoff Cc: caml-list@inria.fr Subject: Re: OO design References: <53c655920605050235k64e70333je8df813239ea3c53@mail.gmail.com> <20060508.121743.65190532.garrigue@math.nagoya-u.ac.jp> <200605082329.36911.David.Teller@ens-lyon.org> <445FB9C7.4040703@cs.washington.edu> <446152CB.5010605@cis.upenn.edu> <44621204.4020601@cs.washington.edu> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 446280AB.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 446280A8.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; upenn:01 monadic:01 stdin:01 stdout:01 wrote:01 functions:01 lisp:01 alan:01 seems:03 suggestion:03 latter:03 implicit:03 implicit:03 passing:03 manipulate:03 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 brogoff wrote: >> A monadic approach (where each >> operation would return a "new" file) or linearity appears necessary for >> the latter. > > Yoann Padioleau's suggestion to use the Lisp approach (with-open-file) > looks like the best approach for ML to me. It has advantages, but I'm not seeing how this prevents the problems with aliasing. Take Till's version (with_open_out), it gives the function the channel itself. There is nothing to stop the function from stashing the channel in a reference cell and then later attempting to use it after it has been closed. So giving the function the channel directly is bad, what about instead passing it some functions to manipulate the open channel? Same problem. Another solution almost solves the problem of never reading from or writing to a closed channel is to have an "implicit" current channel that starts out as stdin/stdout. Then "with-open" would change the current implicit channel. However, this actually just transforms the problem from "trying to read from or write to a closed channel" to "reading from or writing to the wrong channel". The only "solution" that I've seen that seems to actually solve the "problem" is to write a small interpreted language for performing I/O, but that is a bit heavy weight for general use.