From: Nicolas C. <war...@fr...> - 2003-06-20 00:07:06
|
> > I think that one of the thing that could be done is to merge the two modules > > into one > > I made UChar and UTF-8 two different modules because, > > * Char and String are different modules, and I want to make unicode > modules similar to the string API of stdlib as far as possible, and > > * Users, or eventually we, may provide other Unicode string (UTF-16, > UCS-4, BOCU, or whatever). Making UTF-8 an independent module > would make changing Unicode string implementation easier. > > If nested modules are acceptable, we can pack them into one module, of > course. No it's ok this way :-) > > work a little on function/type naming and better exception > > handling. > > Is it better to define its own exception than to use invalid_arg? > Currently, UTF-8 module don't do bound checking itself for the > performance reason. Is it better to do bound checking in UTF-8, and > raise its own exception other than Invalid_arg? Depends. ExtLib exception policy is the following : - if exception should be catched , then use a module-specific exception - if exception is a programmer failure, then you can use invalid_arg or failwith Theses statement come from the fact that invalid_arg and failwith are type-unsafe since you need to catch them with the good string in order to have a correct catching behavior. Using module-specific exceptions, even with a string parameter, reduce the number of bad-catchs. In the case of parsing (xml , unicode, etc.) the data often comes from an external source, and the programmer will most of the time want to handle parsing failures , theses should then not be considered as "exceptions worth catching" and declared as module-specific exceptions. Nicolas Cannasse |