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] How to read three integers from a text-file... ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-05-03 (10:17)
From: Lauri Alanko <la@i...>
Subject: Re: [Caml-list] input_line
On Tue, Apr 30, 2002 at 02:07:20PM +0200, Xavier Leroy wrote:
> > And worst of all, there are no limits on the size of string
> > to be created. So a maliciously designed huge input could blow either
> > the stack or the heap. I wouldn't want to use input_line in a network
> > application.
> I see your point, but there are other (most?) applications where you
> really do not want to have any hard limits beyond available memory.

Well, strings already _have_ a hard limit on their size...

But on second thought, yes, it seems that networking applications do
need features that are beyond what can reasonably be expected from a
Pervasives function. For example, in addition to limiting memory usage,
I also need to implement timeouts. Since there is no way to
asynchronously interrupt threads[1], the only way to make sure a
thread never blocks indefinitely is to use nonblocking IO, which
complicates things a bit.

So I ended up writing my own IO interface on top of the Unix module.
What bothers me about this is that now I cannot use any library
functions that operate on (in|out)_channels. Moreover, I had to
implement basic buffering, although the channel implementations do that

Why, therefore, is it not possible to create standard channels that are
backed by user-defined functions? This is pretty much a standard feature
in many languages, and it would make life easier in many ways.

Lauri Alanko

[1] Or so I gather. The Haskell folks have studied asynchronous
exceptions in PLDI '01 and implemented them in GHC. Perhaps their work
could be adapted for ocaml as well?
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