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
[Caml-list] [ANN] The Missing Library
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-04-26 (22:32)
From: Gerd Stolpmann <info@g...>
Subject: Re: [Caml-list] Re: Common IO structure
On Mon, 2004-04-26 at 23:14, John Goerzen wrote:
> On Mon, Apr 26, 2004 at 10:56:59PM +0200, Gerd Stolpmann wrote:
> > I would suggest to adopt the names "input", "output", "close_in",
> > "close_out" of the standard library, as users are already familiar with
> > them, and this functionality is already quite powerful. Of course, this
> > is only reasonable for byte channels, not for Unicode channels.
> Don't those names seem incompatible with read/write files and
> bidirectional channels such as network sockets?


> (Ok, so close_in and close_out could be mapped to shutdown(2) in the
> latter case, but I very much suspect that would NOT be what a programmer
> woudl suspect...)

That depends on what the object represents. In Unix, shutdown(2) refers
to the connection whereas close(2) refers to the descriptor. That means,
one can close one half of a connection, but not one half of a
descriptor. I think this is a deficiency of the Unix API (which has
historical reasons, bidirectional pipes were added late).

As OO channels are not limited to file descriptors, I don't see why we
should model them strictly after the Unix API. Separating close_in and
close_out has the advantage that input and output behaviour can be
really independent, and it is simpler to inherit input and output
behaviour from different superclasses. When mapping to Unix, one can
implement the rule that the descriptor is closed when both directions
are closed.

With only one "close" for both directions, one cannot model
bidirectional channels without additional methods like "shutdown".

Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany 
gerd@gerd-stolpmann.de          http://www.gerd-stolpmann.de

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