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.1 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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 92BA7BBAF; Wed, 21 Jan 2009 10:38:41 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtIDAMl7dkmBrw8EgWdsb2JhbACTegEBFiK3fYVz X-IronPort-AV: E=Sophos;i="4.37,299,1231110000"; d="scan'208";a="34058906" Received: from ext.lri.fr ([129.175.15.4]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 21 Jan 2009 10:38:40 +0100 Received: from localhost (localhost [127.0.0.1]) by ext.lri.fr (Postfix) with ESMTP id 9FC33A42AE; Wed, 21 Jan 2009 10:38:40 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at lri.fr Received: from ext.lri.fr ([127.0.0.1]) by localhost (ext.lri.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8zi8G6S8x5dp; Wed, 21 Jan 2009 10:38:40 +0100 (CET) Received: from smtp.lri.fr (vhost3-23 [129.175.3.23]) by ext.lri.fr (Postfix) with ESMTP id 86CA5A42AD; Wed, 21 Jan 2009 10:38:40 +0100 (CET) Received: from [129.175.4.107] (lri4-107 [129.175.4.107]) by smtp.lri.fr (Postfix) with ESMTP id 76E60E056A; Wed, 21 Jan 2009 10:38:40 +0100 (CET) Message-ID: <4976ED47.8060001@lri.fr> Date: Wed, 21 Jan 2009 10:39:19 +0100 From: Romain Bardou User-Agent: Thunderbird 2.0.0.18 (X11/20081125) MIME-Version: 1.0 To: Jacques Carette Cc: Luc Maranget , caml-list@inria.fr Subject: Re: [Caml-list] polymorphic variants, long form References: <49760BBF.7090008@mcmaster.ca> <20090120173958.GA24589@yquem.inria.fr> <4976121B.3040109@mcmaster.ca> In-Reply-To: <4976121B.3040109@mcmaster.ca> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Spam: no; 0.00; lri:01 variants:01 maranget:01 struct:01 foo:01 foo:01 syntax:01 'foo:01 ocaml:01 variants:01 abbreviation:01 polymorphic:01 polymorphic:01 wrote:01 luc:01 Jacques Carette a écrit : > Luc Maranget wrote: >>> What is the proper 'long name' of a polymorphic variant? >>> module S = struct type a = [`Foo of int] end >>> >>> How do I refer to `Foo without opening S? Both S.`Foo and `S.Foo are >>> syntax errors. >>> >>> Jacques >>> >> >> 'Foo does the job, it does not refer to any previous type definition. >> >> % ocaml >> Objective Caml version 3.11.0 >> >> # `Foo;; >> - : [> `Foo ] = `Foo >> > Just a few minutes after I sent my email, I remembered the answer > myself: unlike normal variants, polymorphic variants are not scoped but > affect the namespace in a GLOBAL way. Both extremely convenient and > non-modular at the same time. It does not actually affect the namespace, as there is no namespace for polymorphic variants. All variant names can be used, anywhere, and then types are inferred. Your type definition S.a does not declares anything but S.a, which is just a type abbreviation and could be expanded to [`Foo of int] everywhere. -- Romain Bardou