From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q4AF02Vu002014 for ; Thu, 10 May 2012 17:00:02 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ap4CAN/Wq0+MTaZEkWdsb2JhbABEtC0BAQEBFBIUJ4IVAQEFJ1EBEAsYCRMDDwkDAgECASsaBg0BBwEBiAq7R5E7BI53gSOZDg X-IronPort-AV: E=Sophos;i="4.75,565,1330902000"; d="asc'?scan'208";a="157872220" Received: from toccata.ens-lyon.fr (HELO toccata.ens-lyon.org) ([140.77.166.68]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 10 May 2012 16:59:57 +0200 Received: from localhost (localhost [127.0.0.1]) by toccata.ens-lyon.org (Postfix) with ESMTP id 9628C840A2; Thu, 10 May 2012 16:59:55 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at toccata.ens-lyon.org Received: from toccata.ens-lyon.org ([127.0.0.1]) by localhost (toccata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EbLRfgW+5eE5; Thu, 10 May 2012 16:59:55 +0200 (CEST) Received: from Niels.local (mozilla.vlan402.asr1.cdg3.gblx.net [208.49.33.218]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by toccata.ens-lyon.org (Postfix) with ESMTPSA id 472078408F; Thu, 10 May 2012 16:59:55 +0200 (CEST) Message-ID: <4FABD7EA.7080902@ens-lyon.org> Date: Thu, 10 May 2012 16:59:54 +0200 From: David Rajchenbach-Teller Reply-To: David.Teller@ens-lyon.org User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Fabrice Le Fessant CC: Yitzhak Mandelbaum , OCaml mailing list References: In-Reply-To: X-Enigmail-Version: 1.4.1 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig00379082DC20E74B9D583C05" Subject: Re: [Caml-list] optional functions in modules This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig00379082DC20E74B9D583C05 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I would personally use an [option] and a form of startup-time configuration, quite comparable to the browser-feature detection in JavaScript. So, something like let my_function =3D match Module.may_have_feature with | Some implementation -> implementation | None -> (*either a workaround or an error*) Cheers, David On 5/10/12 4:53 PM, Fabrice Le Fessant wrote: > I would say that it depends on how likely it is that somebody is going > to handle the case where the function is not implemented. I would use > a boolean to detect if the function is implemented, and calling the > missing function would raise an exception (be careful to define the > corresponding exception, using failwith "not implemented" might be too > generic to be useful, although I always do it in my programs ;-) ). If > it is highly likely that the program is going to handle the missing > function, using a Some type for the function is better idea. >=20 > -Fabrice >=20 --------------enig00379082DC20E74B9D583C05 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) iQEcBAEBAgAGBQJPq9fqAAoJED+FkPgNe9W+Qo8H/3k35VkWRTwDWxW1I6rb4f/K lhFwmNfm1+kzuHRaur8+mOGA4aoQFhnX0o71LLAaTCb6+sZguNl2M2DRIm4c1CqW QY69cFITIWWfnm7xwB+J/q/tQjBCxdLqRMXimYmpyNucTkktUM6bQF9Suorg4nBZ entsAAhG6IjlqwxalZfwgpCeW/oC3HR7zf77ASi3CfJR6GQxRu1vpdl9o0BWfxxE ueo0KhWwkqsCnh6+JCdOFaLzDIc0m00iOnqfhLxhx3BJXObOeso365bxO5VVOn9u 890hV+np2M+ZZ+OJISiTxGX752oKXszpv3IEoKi5qKECCYtnKIWVhQ5/y/w+MJo= =lw52 -----END PGP SIGNATURE----- --------------enig00379082DC20E74B9D583C05--