caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Brian Hurt <bhurt@spnz.org>
To: Gerd Stolpmann <info@gerd-stolpmann.de>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Common IO classes
Date: Tue, 25 May 2004 14:41:34 -0500 (CDT)	[thread overview]
Message-ID: <Pine.LNX.4.44.0405251417090.6865-100000@localhost.localdomain> (raw)
In-Reply-To: <1085151218.30476.125.camel@ice.gerd-stolpmann.de>

On Fri, 21 May 2004, Gerd Stolpmann wrote:

> Hi list,
> 
> maybe you remember the discussion about common I/O classes. We (Nicolas
> Cannasse, Yamagata Yoriyuki and I) continued the thread privately, and
> agreed upon the following draft:
> 
> http://www.ocaml-programming.de/tmp/IO-Classes.html
> 
> Maybe other library implementors are interested in a common standard,
> and follow this draft (our hope).
> 

I like it.

Some comments:

- I wish that doing a read or write on a closed channel was required to
throw a known, defined, error.  This makes actually catching and handling
the error possible.  As it is, with every library possibly throwing a
different exception or even just silently ignoring the error it's
impossible to deal with the error.

Note that there would still be library-specific exceptions, for 
library-specific errors.  But this is a generic error that all libraries 
have to deal with, and thus should deal with in the same way.

- The problem with returning 0 for non-blocking I/O when no data is 
available is when someone writes:

let really_input chan str idx len =
	let rec loop idx len =
		let rval = chan#input str idx len in
		if rval < len then
			loop (idx + rval) (len - rval)
		else
			()
	in
	loop idx len
;;

Which busy waits for input.  Hmm.  Actually, this isn't a diaster, 
necessarily.  Not optimal, granted, but not a diaster.  I wouldn't have a 
problem saying "don't do that!", except I would like some way to determine 
that I'm dealing with a non-blocking channel, so I know to not do that.

- Differing from the precise semantics of the Unix API isn't evil.  I'd 
much rather have it be defined and precise.  That way I can at least work 
around them in a portable way if they don't do precisely what I want.  
Which my previous example is a demonstration of, by the way.

- Polymorphic I/O is defined as blocking, while Octet I/O may be blocking 
or non-blocking.  Say I'm writting a UTF8 -> UCS4 (as int) converter, 
where I can read 6-7 octet to create one unicode character.  How do I work 
around a non-blocking octet input without busy waiting?

-- 
"Usenet is like a herd of performing elephants with diarrhea -- massive,
difficult to redirect, awe-inspiring, entertaining, and a source of
mind-boggling amounts of excrement when you least expect it."
                                - Gene Spafford 
Brian

-------------------
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


  parent reply	other threads:[~2004-05-25 19:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-21 14:53 Gerd Stolpmann
2004-05-21 18:11 ` Richard Jones
2004-05-21 18:17   ` Nicolas Cannasse
2004-05-21 18:50 ` Benjamin Geer
2004-05-25 19:41 ` Brian Hurt [this message]
2004-05-25 23:50   ` Yamagata Yoriyuki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.44.0405251417090.6865-100000@localhost.localdomain \
    --to=bhurt@spnz.org \
    --cc=caml-list@inria.fr \
    --cc=info@gerd-stolpmann.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).