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 q4AEroWW001486 for ; Thu, 10 May 2012 16:53:50 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnIBAMDVq0/RVde2kGdsb2JhbABEDqElklAIIgEBAQEJCQ0HFAQjghUBAQEEEgIsAS0LAQMMAQUFCw0NISISAQUBChIGExIQh14DCwucVAkDjxeFPicDColNAQULiweGKQSVfYERjU89gViBezs X-IronPort-AV: E=Sophos;i="4.75,565,1330902000"; d="scan'208";a="143355571" Received: from mail-ey0-f182.google.com ([209.85.215.182]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 10 May 2012 16:53:43 +0200 Received: by eabm6 with SMTP id m6so804060eab.27 for ; Thu, 10 May 2012 07:53:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=G7aVInohyDzYJVwrr5PiFYKPDHcDT+f/Vx2WMrftBh8=; b=V1wBnkGfdlpVEtHBpt6pKo4FENPz92zmzhTUECK4q0TCgLu2MI0bfHeygffY2D1xW7 mQpbHDsNSNqFoRaJCVo6lIKaSsNtQ0xgQHh/iEwql3pP46qIJ2nH4Q4ImgfOtZE59RbR MJ1yo7FkSZ7J4A8K0FI9vwVz7KKdgwUjojQQFWCV73/R7WAsSDuGzk37FTJFofPdULRy TZmGVdCX2ZDh/G5lXRqOo83Mj7Fe1Z4QA9FqomstdaVZinwVwngLz3sGzqkqLKJ3gaDq fzQZwREfLKvPLuEz/Qs8tTwtMAaywn4uxTmDPE9HyN9jvXjfcuCrZ1KBASNX2FfG6u6w FjLA== MIME-Version: 1.0 Received: by 10.50.169.65 with SMTP id ac1mr4211162igc.54.1336661623058; Thu, 10 May 2012 07:53:43 -0700 (PDT) Sender: fabrissimo@gmail.com Received: by 10.42.117.3 with HTTP; Thu, 10 May 2012 07:53:43 -0700 (PDT) In-Reply-To: References: Date: Thu, 10 May 2012 16:53:43 +0200 X-Google-Sender-Auth: EIudjAXoNBJHutjT24TsBXRxSR4 Message-ID: From: Fabrice Le Fessant To: Yitzhak Mandelbaum Cc: OCaml mailing list Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id q4AEroWW001486 Subject: Re: [Caml-list] optional functions in modules 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. -Fabrice On Thu, May 10, 2012 at 2:22 PM, Yitzhak Mandelbaum wrote: > 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 > > > > > > -- > 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 > -- Fabrice LE FESSANT