From: Dustin S. <du...@sp...> - 2003-12-10 06:09:04
|
Hi *, I was just looking through ocaml-lib and I've got a few contributions you guys might be interested in: For ExtString: val split : string -> char -> int -> string list val split_chars : string -> char list -> int -> string list val strstr : string -> string -> int -> int val ends_with : string -> string -> bool val begins_with : string -> string -> bool These are the first things I did in ocaml because I pretty much can't stand regex (and this is about 4x faster than doing the same with basic regex). Looks like you've got some of that in CVS. I notice your todo list includes a wish for base64 support. I just completed this: exception Invalid_encode_chunk of int val char_map : char array val stream_convert : string Stream.t -> char Stream.t val encode_chunk : char list -> string val encode_stream_chunk : char Stream.t -> int -> string option val encode : char Stream.t -> string Stream.t val encode_to_string : char Stream.t -> string val encode_string : string -> string exception Invalid_decode_chunk of int val char_index : int array val is_base64_char : char -> bool val decode_chunk : char list -> string val decode : char Stream.t -> string Stream.t val decode_to_string : char Stream.t -> string val decode_string : string -> string ...I was getting ready to do url encoding and decoding as well in the form of a CGI lib. -- SPY My girlfriend asked me which one I like better. pub 1024/3CAE01D5 1994/11/03 Dustin Sallings <du...@sp...> | Key fingerprint = 87 02 57 08 02 D0 DA D6 C8 0F 3E 65 51 98 D8 BE L_______________________ I hope the answer won't upset her. ____________ |
From: Nicolas C. <war...@fr...> - 2003-12-10 06:24:16
|
> Hi *, > > I was just looking through ocaml-lib and I've got a few contributions > you guys might be interested in: > > For ExtString: > > val split : string -> char -> int -> string list > val split_chars : string -> char list -> int -> string list > val strstr : string -> string -> int -> int > val ends_with : string -> string -> bool > val begins_with : string -> string -> bool Are theses not already in ExtString ? ( you need to look the documentation into ExtString.String module on the website, or edit the CVS version of extString.mli that might be up-to-date ) > These are the first things I did in ocaml because I pretty much can't > stand regex (and this is about 4x faster than doing the same with basic > regex). Looks like you've got some of that in CVS. > > I notice your todo list includes a wish for base64 support. I just > completed this: > > exception Invalid_encode_chunk of int > val char_map : char array > val stream_convert : string Stream.t -> char Stream.t > val encode_chunk : char list -> string > val encode_stream_chunk : char Stream.t -> int -> string option > val encode : char Stream.t -> string Stream.t > val encode_to_string : char Stream.t -> string > val encode_string : string -> string > > exception Invalid_decode_chunk of int > val char_index : int array > val is_base64_char : char -> bool > val decode_chunk : char list -> string > val decode : char Stream.t -> string Stream.t > val decode_to_string : char Stream.t -> string > val decode_string : string -> string > > ...I was getting ready to do url encoding and decoding as well in the > form of a CGI lib. Handling strings are char or int arrays is very inefficient, and Streams are not used in the Extlib. Please look at Enum modules and try to express your lists , arrays and streams as enums, this will make your code a lot more plugable into the Extlib. Regards, Nicolas Cannasse |
From: Dustin S. <du...@sp...> - 2003-12-10 06:44:26
|
On Dec 9, 2003, at 22:24, Nicolas Cannasse wrote: >> val split : string -> char -> int -> string list >> val split_chars : string -> char list -> int -> string list >> val strstr : string -> string -> int -> int >> val ends_with : string -> string -> bool >> val begins_with : string -> string -> bool > > Are theses not already in ExtString ? > ( you need to look the documentation into ExtString.String module on > the > website, or edit the CVS version of extString.mli that might be > up-to-date ) Yeah, I pasted that before looking in CVS. > Handling strings are char or int arrays is very inefficient, and > Streams are > not used in the Extlib. > Please look at Enum modules and try to express your lists , arrays and > streams as enums, this will make your code a lot more plugable into the > Extlib. Those arrays are lookup tables. Are you certain Enum is faster than char_map.(x) ? Enum might make sense to use in place of the Streams. Is there a reason Streams shouldn't be used? How about a Stream and Enum conversion module? -- SPY My girlfriend asked me which one I like better. pub 1024/3CAE01D5 1994/11/03 Dustin Sallings <du...@sp...> | Key fingerprint = 87 02 57 08 02 D0 DA D6 C8 0F 3E 65 51 98 D8 BE L_______________________ I hope the answer won't upset her. ____________ |
From: Nicolas C. <war...@fr...> - 2003-12-10 07:08:35
|
> > Handling strings are char or int arrays is very inefficient, and > > Streams are > > not used in the Extlib. > > Please look at Enum modules and try to express your lists , arrays and > > streams as enums, this will make your code a lot more plugable into the > > Extlib. > > Those arrays are lookup tables. Are you certain Enum is faster than > char_map.(x) ? Enum might make sense to use in place of the Streams. Why then don't you use a string ? String.unsafe_get chars x is faster than an array access, due to special array cases (float arrays) that are checked at runtime. But this is an implementation trick, it shouldn't be visible from outside the API. And bounds have to be check ( and specific exception raised ) before accessing the string of course. > Is there a reason Streams shouldn't be used? How about a Stream and > Enum conversion module? Streams are good for what they have been designed for : stream parsers. They shouldn't be used to represent abstract collections of elements : enum have been designed for that , have a more rich api ( with some nice features such as clone ) and an optimized implementation. Extlib provide a lot of functions to work withs enums , an Enum.to_stream and of_stream could be added but then every user using enums will have to link also the Stream module.... But it's quite easy to write : let to_stream e = Stream.from (fun _ -> Enum.get e) Nicolas Cannasse |