Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Some/None
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-04-24 (14:28)
From: Remi VANICAT <vanicat@l...>
Subject: Re: [Caml-list] Some/None
Oliver Bandel <> 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
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: