Core's approach to this is to use options.  (Technically, we use a
type called Or_error.t, which has a useful error message in the
error-variant, but it's the same idea.)

On Thu, May 10, 2012 at 2:44 PM, Goswin von Brederlow <goswin-...@web.de> wrote:
> Yitzhak Mandelbaum <yitzh...@cs.princeton.edu> writes:
>
>> Hi,
>>
>> Is there any "common wisdom" regarding the inclusion of optional functions 
>> in a module signature?  The two most obvious approaches involve 1) a pair of 
>> boolean flag and a function, where the function raises an exception if 
>> unimplemented OR 2) using the option type. I see pros/cons to each approach, 
>> but am curious if there's any (unofficial) standard approach.
>>
>> Yitzhak
>> -----------------------------
>> Yitzhak Mandelbaum
>
> The extunix module has a trifold solution for this:
>
> * First there is the ExtUnix.All module that has all functions in
>  it. Functions that are not available raise Not_available with function
>  name as an argument.
>
> * Second there is ExtUnix.All.have : string -> bool option
>
>  (** [have name]
>    @return indication whether function [name] is available
>    - [Some true] if available
>    - [Some false] if not available
>    - [None] if not known
>
>    e.g. [have "eventfd"]
>  *)
>
> * Third there is ExtUnix.Specific containing only functions available on
>  this platform.
>
> MfG
>        Goswin
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>


-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to