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=none autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 8D315BC6C for ; Sat, 28 Jul 2007 15:26:39 +0200 (CEST) Received: from bsd4.nyct.net (mail-out8.nyct.net [216.139.141.8]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l6SDQaUL021372 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 28 Jul 2007 15:26:39 +0200 Received: from [192.168.42.2] (adsl-216-139-154-52.nyct.net [216.139.154.52]) by bsd4.nyct.net (8.13.4/8.13.4) with ESMTP id l6SDQX0x050074; Sat, 28 Jul 2007 09:26:34 -0400 (EDT) (envelope-from bhurt@spnz.org) Date: Sat, 28 Jul 2007 09:36:42 -0400 (EDT) From: Brian Hurt X-X-Sender: bhurt@localhost To: Basile STARYNKEVITCH Cc: caml-list@inria.fr Subject: Re: [Caml-list] Re: Void type? In-Reply-To: <46AAFA8F.1000501@starynkevitch.net> Message-ID: References: <20070728075825.GA3508@galois> <46AAFA8F.1000501@starynkevitch.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Miltered: at discorde with ID 46AB440C.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; basile:01 failwith:01 2007,:98 unbound:01 wrote:01 exception:01 caml-list:01 functions:01 functions:01 int:01 int:01 loops:02 arg:03 arg:03 exit:04 On Sat, 28 Jul 2007, Basile STARYNKEVITCH wrote: > A void type would be useful for bizarre functions like f : int -> void > this would mean that f never returns normally, i.e. that it loops > indefinitely, or calls exit (to stop the entire program), or throws an > exception but never returns. The proper type for these functions would be f : int -> 'a. Take a look at invalid_arg and failwith as examples. The advantage of having them return an unbound 'a is that then unifies with any other given type, allowing you to write code like: if (some_test) then some_value else invalid_arg "some_test failed!" and have it work for all possible return types of some_value. Brian