Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Yamagata Yoriyuki <yoriyuki@m...>
Subject: Re: [Caml-list] Re: Common IO structure
From: Gerd Stolpmann <info@gerd-stolpmann.de>
Subject: Re: [Caml-list] Re: Common IO structure
Date: Mon, 26 Apr 2004 22:56:59 +0200

> Of course, sharing the same method name is possible, in ocamlnet we have
> e.g. output_char where camomile has put_char. So the question is whether
> this is worth the effort.

Camomile uses "put", not "put_char", because channels are polymorphic.
If ocamlnet channels have input/output for strings, but have
output_char for one Unicode character, then I would say output_char is
different from Camomile "put", because Camomile "put" is supposed to
output one atom (for character channles, atom is char, not a Unicode
character.)

Since I am convinced by Gerd's argument for close_in/close_out, I
updates my proposal as
(for input)
['a] object 
     get : unit -> 'a 
     close_in : unit
end 
(raise End_of_file when there is no more element to read.)

(for output)
['a] object 
     put : 'a -> unit 
     flush : unit -> unit 
     close_out : unit -> unit
end

for a character channel,
(for input)
object 
       input : string -> int -> int -> int 
       close_in : unit
end

([c#input s pos len] fills s from pos with less than [len] characters,
and returns the number of characters really filled.)

(for output)
object 
       output : string -> int -> int -> unit
       flush : unit -> unit
       close_out : unit -> unit
end
([c#output s pos len] outputs [len] characters from the position
[pos])

But the distinction of put/input, get/output may be confusing.  Hmmm.

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