From: Stefano Z. <za...@bo...> - 2003-02-28 13:16:09
|
On Fri, Feb 28, 2003 at 12:38:12PM +0900, Nicolas Cannasse wrote: > > (* like perl's chomp function, remove trailing newline characters *) > > - val String.chomp : string -> string > Uhm, why not, but this need some discuss on implementation since newline is > "\r\n" under windows and "\n" under *nix.... Yes, but I'm almost sure that somewhere this information is already available in the standard library. Think for example at the input_line function that read a line from an input channel without trailing "newline", on *nix it removes the trailing "\n" but I'm almost sure that under win it removes trailing "\r\n" and so on on mac. > perhaps : > val iter_in : (string -> unit) -> in_channel -> unit > val map_in : (string -> 'a) -> in_channel -> 'a list > val fold_in : ('a -> string -> 'a) -> 'a -> in_channel -> 'a > > are better so it can work on many kind of descriptors and does not have to > handle the "file not found" problems Agreed. > I propose also : > val read_lines : in_channel -> string list Better "input_lines" for coherence with Pervasives.input_line > val read_all : in_channel -> string Better "input_all", "read_*" prefixed functions in Pervasives act on stdin only and not on generic input channels. Therefore I also suggest "read_lines" which is a "input_lines" working on stdint and "read_all", the same for "input_all". Anyway is probably worthwhile to think at something like: val input_lines: ?inchan:in_channel -> string list val input_line: ?inchan:in_channel -> string with optional argument "inchan" defaulting to "stdin". This makes standard library more compact. > > - val Dbm.fold_left > Uh, never used Dbm... Ok, but trust me, a fold function is always useful! :-) > > - val Hashtbl.sorted_fold: ?compare: ('a -> 'a -> int) -> ('a -> 'b -> > > - val Hashtbl.sorted_iter: ?compare: ('a -> 'a -> int) -> ('a -> 'b -> > Aren't theses strange and very particular ones ?? Probably you are right, they are uncommon also in other standard libraries ... not really useful indeed. > All theses cannot be part of the ExtLib, since we're only focusing right now > on the StdLib Extension ( and Unix is not part of the StdLib altought it's > part of the standard distribution ) and also theses function need some C > code to work. Ok, we probably disagree on the idea of "standard library", I was thinking at it like "all the libraries that are part of the ocaml distribution". If you are looking only at Pervasives module remember that also Dbm isn't part of it ... > > - val Random.char: unit -> char > > - val Random.string: int -> char (* argument is string length *) > Don't like theses Why? > > - val non: ('a -> bool) -> ('a -> bool) > Since there is some need for such basic functions, let's put that in a > module Logic Is it worth the effort? Have you find many other functions for this module? > > - val unsome : 'a option -> 'a > Global is much more complete Uh? Cheers. -- Stefano Zacchiroli - Undergraduate Student of CS @ Uni. Bologna, Italy zack@{cs.unibo.it,debian.org,bononia.it} - http://www.bononia.it/zack/ " I know you believe you understood what you think I said, but I am not sure you realize that what you heard is not what I meant! " -- G.Romney |