From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id D8F55BBC1 for ; Thu, 21 Feb 2008 13:21:35 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAMb6vEfAXQInh2dsb2JhbACQXQEBAQgKKZ56 X-IronPort-AV: E=Sophos;i="4.25,386,1199660400"; d="scan'208";a="7537065" Received: from concorde.inria.fr ([192.93.2.39]) by mail2-smtp-roc.national.inria.fr with ESMTP; 21 Feb 2008 13:21:35 +0100 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m1LCLZEZ018415 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 21 Feb 2008 13:21:35 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAD/7vEfBMVMQh2dsb2JhbACQXQEBAQgKKZ58 X-IronPort-AV: E=Sophos;i="4.25,386,1199660400"; d="scan'208";a="22866866" Received: from unknown (HELO min.univ-orleans.fr) ([193.49.83.16]) by mail4-smtp-sop.national.inria.fr with ESMTP; 21 Feb 2008 13:21:35 +0100 Received: from smtps.univ-orleans.fr (localhost [127.0.0.1]) by min.univ-orleans.fr (Postfix) with ESMTP id 7F61312B35A; Thu, 21 Feb 2008 13:21:32 +0100 (CET) Received: from [192.168.0.12] (ras75-4-82-235-58-110.fbx.proxad.net [82.235.58.110]) by smtps.univ-orleans.fr (Postfix) with ESMTP id EC03236E5B; Thu, 21 Feb 2008 13:21:33 +0100 (CET) Subject: Re: [Caml-list] Auto-closing polymorphic variants ? From: David Teller To: Jacques Garrigue Cc: caml-list@inria.fr In-Reply-To: <20080221.105405.42787647.garrigue@math.nagoya-u.ac.jp> References: <1203541049.11853.36.camel@Blefuscu> <20080221.105405.42787647.garrigue@math.nagoya-u.ac.jp> Content-Type: text/plain Date: Thu, 21 Feb 2008 13:21:31 +0100 Message-Id: <1203596491.6304.18.camel@Blefuscu> Mime-Version: 1.0 X-Mailer: Evolution 2.12.1 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 47BD6CCF.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; variants:01 univ-orleans:01 ocaml:01 matchings:01 variants:01 inference:01 cheers:01 univ-orleans:01 lifo:01 liquidations:98 polymorphic:01 polymorphic:01 wrote:01 caml-list:01 interfaces:01 On Thu, 2008-02-21 at 10:54 +0900, Jacques Garrigue wrote: > This does not mean that we can try nothing. For instance we could > introduce a warning when a pattern matching adds a new tag to a > polymorphic input. The idea is that since the input is polymorphic, it > is sure that it will never actually contain extra tags. > And thanks to the relaxed value restriction, the result of safe_div > would be just polymorphic enough to trigger the warning, while example > like the above, by being not polymorphic, would not trigger it. > But this would not be easy to implement... Sounds like a good idea. How hard would that be ? > > Of course, we could do that by manually closing the type of safe_div, > > but this would essentially mean duplicating information. > > > It is better to either define safe_div as returning a closed variant > type (writing interfaces in ocaml _is not_ code duplication, it is > code specification!) or not use wild cards in pattern matchings > on open polymorphic variants. I agree that, whenever module barriers are crossed, interfaces become specifications. However, as soon as you're remaining inside one module, it's nice to be more lightweight and just let inference handle everything. This is where a warning (or something like a "close" operator) would come in handy. Cheers, David -- David Teller Security of Distributed Systems http://www.univ-orleans.fr/lifo/Members/David.Teller Angry researcher: French Universities need reforms, but the LRU act brings liquidations.