English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
OO design
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-05-11 (00:09)
From: Geoffrey Alan Washburn <geoffw@c...>
Subject: Re: OO design
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.