From: Nicolas C. <war...@fr...> - 2003-03-11 01:48:51
|
> > I disagree: val_of has two reasonable uses. First, it can be > > used with throwaway prototype programs, where simplicity and speed > > matter more than correctness. Second, it can be used where the semantics > > of the program dictate that the option has "Some" value. If you don't > > have a "Some" value in these cases, there often is nothing to do > > except bail out in the "with" clause, so you might as well catch > > the exception somewhere else higher up. > > Agreed. I use Some values for my command line options which I verify > before I use them, so I'd like to use them easily. Okay, so perhaps somethink like : let val_of = function | None -> failwith "val_of" | Some x -> x is what you need ? But since I think some people will still want to catch the exception and use try...with instead of an easier pattern matching ( perhaps catching the exception to an upper level can be useful sometimes ), I would prefer : exception ValNone let val_of = function | None -> raise ValNone | Some x -> x Nicolas Cannasse |