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