From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 88558BB91 for ; Thu, 16 Dec 2004 20:22:58 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id iBGJMwVY009818 for ; Thu, 16 Dec 2004 20:22:58 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA26276 for ; Thu, 16 Dec 2004 20:22:57 +0100 (MET) Received: from alex.barettalocal.com (h213-255-109-130.albacom.net [213.255.109.130] (may be forged)) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id iBGJMvDY021653 for ; Thu, 16 Dec 2004 20:22:57 +0100 Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) by alex.barettalocal.com (Postfix) with ESMTP id E0B2D2BAA94; Thu, 16 Dec 2004 20:22:57 +0100 (CET) Message-ID: <41C1E091.1040508@barettadeit.com> Date: Thu, 16 Dec 2004 20:22:57 +0100 From: Alex Baretta User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041007 Debian/1.7.3-5 X-Accept-Language: it, en-us, en MIME-Version: 1.0 To: Ocaml , Luca Pascali , Ernesto Ferrari , Domenico Cosentino Cc: Gerd Stolpmann Subject: Dummy polymorphic constructors Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 41C1E092.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 41C1E091.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; baretta:01 constructors:01 ocaml:01 syntax:01 -naur:01 parsing:01 parser:01 patched:01 parsing:01 parser:01 patched:01 baretta:01 ptyp:01 ptyp:01 polymorphic:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.0 X-Spam-Level: Currently ocaml does not support empty polymorphic variant sum types. Say, I cannot write the following. type empty = [ ] This fails due to a syntax error rather than a typing error, which is a sensible, given that the type expression I have written is actually perfectly meaningful. Is there a design decision behind this, or have the Caml breeders simply overlooked the potential need for empty types? What do you guys think of the following patch? Alex diff -Naur stable/parsing/parser.mly patched/parsing/parser.mly --- stable/parsing/parser.mly 2004-12-16 20:15:53.000000000 +0100 +++ patched/parsing/parser.mly 2004-12-16 20:16:16.000000000 +0100 @@ -10,6 +10,9 @@ /* */ /***********************************************************************/ +/* Patched by Baretta DE&IT to add support for empty variant types */ + + /* $Id: parser.mly,v 1.120 2004/05/19 12:15:19 doligez Exp $ */ /* The parser definition */ @@ -1285,8 +1288,8 @@ { mktyp(Ptyp_variant([$2], true, None)) } | LBRACKET BAR row_field_list RBRACKET { mktyp(Ptyp_variant(List.rev $3, true, None)) } - | LBRACKET row_field BAR row_field_list RBRACKET - { mktyp(Ptyp_variant($2 :: List.rev $4, true, None)) } + | LBRACKET row_field_list RBRACKET + { mktyp(Ptyp_variant(List.rev $2, true, None)) } | LBRACKETGREATER opt_bar row_field_list RBRACKET { mktyp(Ptyp_variant(List.rev $3, false, None)) } | LBRACKETGREATER RBRACKET @@ -1297,7 +1300,8 @@ { mktyp(Ptyp_variant(List.rev $3, true, Some (List.rev $5))) } ; row_field_list: - row_field { [$1] } + /* empty */ { [] } + | row_field { [$1] } | row_field_list BAR row_field { $3 :: $1 } ; row_field: -- ********************************************************************* http://www.barettadeit.com/ Baretta DE&IT A division of Baretta SRL tel. +39 02 370 111 55 fax. +39 02 370 111 54 Our technology: The Application System/Xcaml (AS/Xcaml) The FreerP Project