From: Nicolas C. <war...@fr...> - 2004-04-26 15:09:02
|
> On Mon, Apr 26, 2004 at 09:34:42AM +0200, Nicolas Cannasse wrote: > > Some comments : > > - the ConfigParser is nice, but lacks some persitency and typing. I would > > By this I assume you mean something akin to Marshal, where you can throw > an OCaml object at it and always get back the same one (as opposed to > the getint(), getbool(), etc. that are in ConfigParser). > > One problem with that approach is that is goes against the easily > user-editable goal, where users should be able to just put values in the > config file and not worry too much about the app. Note, though, that > ConfigParser does define functions to write out the in-memory structure > to a file or string. Then we need to do it. Symbols are provinding flexible typing, that means that we can put any type in a symbol. If we had a data structure consisting only of, let's say : type data = | Object of (string * data) list | Int of int | Float of float | String of string | Bool of bool as well as : let load_data : appname:string -> data let save_data : appname:string -> data -> unit and the module handling well the OS particuliraties (that is : putting the data in an user-readable format at the good place, whatever it could be) then we have a winning combinaison of typing and persistence (we're loosing here only the openness of types since we're limited by our own parser/printers : a generic type with custom parser/printers could be enabled). > > IMHO, it would be nice to have some persistant storage for configuration > > data which would be stored in a single user database file and made > > accessible for all ocaml programs ( a little like a portable windows > > registry ) > > Perhaps some would like this, and perhaps ConfigParser could be modified > to serve that purpose. I, OTOH, would not like that. In general, I > think that users do not care what language a program is written in if it > does what they want. Users are more likely to think "Where do I go to > configure app foo?" than "What language is app foo written in, and where > does it store config data?" Then it's best to help with the programmer and enforce the data store where it should be, without the need for him to port on other systems. > Moreover, a shared file like that brings in locking-related issues that > are not necessarily present with individual app-specific configuration > files. It also goes against the grain of what people expect on a *nix > system and makes it more difficult for people to write tools to generate > config files for a given app in an automated fashion. You're true about this, I dismiss the idea of having one single big file. But having a file per application name looks nice. (more following) Nicolas Cannasse |