From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q4AIiOYn007023 for ; Thu, 10 May 2012 20:44:24 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: At4BAKcLrE/ZSMDjgGdsb2JhbABEDrQHIgEBCwsLBRYDJIIVAQEEAScTPwULCyElDwEEKCETG4dkAQkJsSsfiguROwSbX40OOw X-IronPort-AV: E=Sophos;i="4.75,565,1330902000"; d="scan'208";a="143383565" Received: from fmmailgate02.web.de ([217.72.192.227]) by mail4-smtp-sop.national.inria.fr with ESMTP; 10 May 2012 20:44:18 +0200 Received: from moweb001.kundenserver.de (moweb001.kundenserver.de [172.19.20.114]) by fmmailgate02.web.de (Postfix) with ESMTP id 8FD081C487447 for ; Thu, 10 May 2012 20:44:06 +0200 (CEST) Received: from frosties.localnet ([95.208.118.96]) by smtp.web.de (mrweb001) with ESMTPA (Nemesis) id 0MK2JZ-1SRizo3aAX-001Ofc; Thu, 10 May 2012 20:44:05 +0200 Received: from mrvn by frosties.localnet with local (Exim 4.77) (envelope-from ) id 1SSYLN-00039m-5c; Thu, 10 May 2012 20:44:05 +0200 From: Goswin von Brederlow To: Yitzhak Mandelbaum Cc: OCaml mailing list References: Date: Thu, 10 May 2012 20:44:05 +0200 In-Reply-To: (Yitzhak Mandelbaum's message of "Thu, 10 May 2012 08:22:51 -0400") Message-ID: <87d36bnafe.fsf@frosties.localnet> User-Agent: Gnus/5.110009 (No Gnus v0.9) XEmacs/21.4.22 (linux, no MULE) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Provags-ID: V02:K0:S7scsgGH76fvKRrPTdURPJZCVDxmvi6lasfYQMs3sDo +3lAL9WDzw+N55l272LNw6EnCneZVSteSbE6L0wUVn01ogDGTf vWTVdx5J73J6oRf4glfOjJWeBuTQHcg3nxk0IGYjs3Gak9eLwE 0APS2M/3NbPOfjFR3G6htRp598M7vToJYT0dmU0RFHW5ItG7hK ltgAYrKtmpcEDU+0gHQ8Q== Subject: Re: [Caml-list] optional functions in modules Yitzhak Mandelbaum 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