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 MAA28268; Fri, 3 May 2002 12:17:57 +0200 (MET DST) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id MAA28277 for caml-list@pauillac.inria.fr; Fri, 3 May 2002 12:17:57 +0200 (MET DST) 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 KAA25087 for ; Fri, 3 May 2002 10:12:17 +0200 (MET DST) Received: from porsta.cs.Helsinki.FI (porsta.cs.Helsinki.FI [128.214.48.124]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g438CGP25988 for ; Fri, 3 May 2002 10:12:16 +0200 (MET DST) Received: from alkokrunni.cs.Helsinki.FI (sslwrap@localhost [127.0.0.1]) by porsta.cs.Helsinki.FI (8.11.6/8.11.6) with ESMTP id g438CAB19248 for ; Fri, 3 May 2002 11:12:11 +0300 Received: from localhost (lealanko@localhost) by alkokrunni.cs.Helsinki.FI (8.11.6/8.11.2) with SMTP id g438C9a30197 for ; Fri, 3 May 2002 11:12:10 +0300 X-Authentication-Warning: alkokrunni.cs.Helsinki.FI: lealanko owned process doing -bs Received: from la by la.iki.fi with local (Exim 3.33 #1 (Debian)) id 173Qhq-0000WK-00 for ; Fri, 03 May 2002 03:13:50 +0300 Date: Fri, 3 May 2002 03:13:48 +0300 From: Lauri Alanko To: caml-list@inria.fr Subject: Re: [Caml-list] input_line Message-ID: <20020503001348.GA577@la.iki.fi> References: <4.3.2.7.2.20020424222749.02d10a90@mail.d6.com> <15557.14957.358556.545541@absurd.mimuw.edu.pl> <15557.14957.358556.545541@absurd.mimuw.edu.pl> <4.3.2.7.2.20020424222749.02d10a90@mail.d6.com> <4.3.2.7.2.20020425104214.02e42a90@mail.d6.com> <3CCA2C6E.5020007@ozemail.com.au> <20020427160209.GB675@la.iki.fi> <20020430140720.A19609@pauillac.inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020430140720.A19609@pauillac.inria.fr> User-Agent: Mutt/1.3.25i Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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 already. 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 la@iki.fi [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