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 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id C3AE6BC69 for ; Sun, 29 Jul 2007 14:43:44 +0200 (CEST) Received: from furbychan.cocan.org (furbychan.cocan.org [80.68.91.176]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l6TChiRD014942 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Sun, 29 Jul 2007 14:43:44 +0200 Received: from rich by furbychan.cocan.org with local (Exim 3.35 #1 (Debian)) id 1IF87Y-0005br-00; Sun, 29 Jul 2007 13:43:40 +0100 Date: Sun, 29 Jul 2007 13:43:40 +0100 To: Arnaud Spiwack Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Re: Void type? Message-ID: <20070729124340.GA18564@furbychan.cocan.org> References: <46AC748B.10200@lix.polytechnique.fr> <200707291216.34682.jon@ffconsultancy.com> <46AC7BB8.8050609@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <46AC7BB8.8050609@gmail.com> User-Agent: Mutt/1.5.9i From: Richard Jones X-Miltered: at concorde with ID 46AC8B80.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; 0200,:01 syntax:01 syntax:01 ocaml:01 val:01 failwith:01 val:01 failwith:01 wrote:01 wrote:01 arnaud:01 arnaud:01 caml-list:01 exceptions:01 int:01 On Sun, Jul 29, 2007 at 01:36:24PM +0200, Arnaud Spiwack wrote: > Jon Harrop a écrit : > >On Sunday 29 July 2007 12:05:47 Arnaud Spiwack wrote: > > > >>It is the good solution if you work with the original syntax (and it's > >>absolutely equivalent to the dual definition in term of empty variant > >>which you can write in the revised syntax). > >> > > > >I don't quite understand this "empty variant from the revised syntax > >thing". How is: > > > > type void > > > >not an empty variant? > > > > > Well, not technically I believe. It's a type with no definition. I > wouldn't be adamant about that but I reckon it's not considered as a sum > type by OCaml type system. > Plus you cannot write the empty matching : > match x with [] > in the original syntax, preventing you from writing a function of type > void -> 'a without using exceptions or Obj.magic or an obviously > looping function or such. > > Thus it does not really have the logical behavior of an empty variant. Can you explain what you mean a bit more? type void1 = { v: 'a. 'a };; let f (_ : void1) = 1;; --> val f : void1 -> int = let f () : void1 = failwith "error";; --> val f : unit -> void1 = type void2;; let f (_ : void2) = 1;; --> val f : void2 -> int = let f () : void2 = failwith "error";; --> val f : unit -> void2 = They seem to be fairly similar to me. Rich. -- Richard Jones Red Hat