Browse thread
[Caml-list] Some/None
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Remi VANICAT <vanicat@l...> |
| Subject: | Re: [Caml-list] Some/None |
Oliver Bandel <oliver@first.in-berlin.de> writes: > But I have to think about it in more detail. > Does it make sense to give back None/Some > out of a function (e.g. is_regularfile/is_directory/...) > or is it only useful inside functions in > try- and match-statements? Really ? it depend. in case of is_regularfile/is_directory/... these function seem to be test, they should return boolean. more generally, the main question is "is absence of value is very common, a normal behavior, or is it only a exceptional behavior ?". In the first case, I will probably use an optional value, and in the second case I will probably return a plain value, and raise an exception in the case there is no value. One can see that it's not widely use in the ocaml library, because most of the case are better handled by exception. But for example, the weak array of the module Weak contain value that may disappeared, an so use the option type. -- Rémi Vanicat vanicat@labri.u-bordeaux.fr http://dept-info.labri.u-bordeaux.fr/~vanicat ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners