From: Nicolas C. <war...@fr...> - 2004-08-14 08:58:01
|
> Would extLib be interested in a general purpose Environment > interaction module? Here's what I have fully implemented > so far: > > (** Various functions and classes for interacting with the environment > *) > > (** {1 Functions for interacting with the current process environment } *) > > val get : string -> string > val strict_get : string -> string > val default : ?def:string -> string -> string > val put : string -> string -> unit What are differences between default, get, and strict_get ? I think two functions would be enough : val get : string -> string option val default : def:string -> env:string -> string > (** {1 Class for interacting with a local fabricated environment } *) > > class env : > ?env:string array -> > ?size:int -> > unit -> > object > val mutable env_h : (string, string) Hashtbl.t > method environment : unit -> string array > method fold : (string -> string -> 'a -> 'a) -> 'a -> 'a > method get : string -> string > method iter : (string -> string -> unit) -> unit > method length : unit -> int > method put : string -> string -> unit > method remove : string -> unit > end This is an object wrapper of an Hashtbl, it has nothing to do with environnement. Why not simply : module Env -------------- type t = (string , string ) Hashtbl.t val get : t -> string -> string option val default : t -> def:string -> env:string -> string val process : unit -> t val dup : t -> t val to_array : t -> string array ------------------ Now if you want to use object syntax for any container (Hashtbl, list, array....) you might want to write an OO wrapper on Enums : class 'a enum : 'a Enum.t -> object ... end Nicolas Cannasse |