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=1.2 required=5.0 tests=AWL,SPF_NEUTRAL 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 EECB1BC0B for ; Sat, 6 Jan 2007 01:52:26 +0100 (CET) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.174]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l060qQ8P014097 for ; Sat, 6 Jan 2007 01:52:26 +0100 Received: by ug-out-1314.google.com with SMTP id q2so7013466uge for ; Fri, 05 Jan 2007 16:52:24 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=aKehHuTyOgL5Wfmj8qhkQEoT2yS2J07wpGPJB0yWRZDTAsYs1g8Z2pmN148jjTcc/yhFYme5RcEeN6nzUBNBL/kK0rxy1G/9LI+7DGPzo/M9+8K9d2VznCxUUVxu6W8eTKiYVK+eGZpWOZbS0ZMNKJ3rD22zBfhTnsCLrRRD0Yg= Received: by 10.78.118.19 with SMTP id q19mr3382078huc.1168044744200; Fri, 05 Jan 2007 16:52:24 -0800 (PST) Received: by 10.78.198.14 with HTTP; Fri, 5 Jan 2007 16:52:24 -0800 (PST) Message-ID: Date: Fri, 5 Jan 2007 16:52:24 -0800 From: "Nathaniel Gray" To: "=?ISO-8859-1?Q?Mattias_Engdeg=E5rd?=" Subject: Re: [Caml-list] Question on writing efficient Ocaml. Cc: garrigue@math.nagoya-u.ac.jp, caml-list@yquem.inria.fr, skaller@users.sourceforge.net In-Reply-To: <200612291115.kBTBF9E26561@virtutech.se> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <200612281626.38328.jon@ffconsultancy.com> <1167326001.5338.0.camel@rosella.wigram> <20061229.150507.32045202.garrigue@math.nagoya-u.ac.jp> <200612291115.kBTBF9E26561@virtutech.se> X-j-chkmail-Score: MSGID : 459EF2CA.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 459EF2CA.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 mattias:01 mattias:01 ocaml:01 val:01 val:01 cheers:01 innocent:98 wrote:01 constructor:01 caml-list:01 explicitly:01 binary:01 int:01 int:01 On 12/29/06, Mattias Engdeg=E5rd wrote: > >In general, I wouldn't explicitly advise against using single > >constructor type definitions for documentation, except when the > >argument is a single int or float and performance matters. > > Is there a reason for this? To my innocent eyes, code like > > type length =3D Length of int > > looks quite reasonable and could be useful at times. I agree. Sadly, the ocaml devs don't. http://caml.inria.fr/mantis/view.php?id=3D3978 As Xavier points out, one can use modules to hide basic types, but this is pretty clumsy in practice. There's rumored to be a solution using phantom types, but my attempts don't work: # type 'a boink =3D int;; type 'a boink =3D int # let f =3D (20 : string boink);; val f : string boink =3D 20 # let g =3D (30 : int boink);; val g : int boink =3D 30 # f;; - : string boink =3D 20 # g;; - : int boink =3D 30 # f + g;; - : int =3D 50 > If binary compatibility with old OCaml releases would be the reason, > is there a policy stating when such ABI details can be changed? The ocaml devs have been quite clear that the ABI can change at any time, so that's not the reason. Cheers, -n8 --=20 >>>-- Nathaniel Gray -- Caltech Computer Science ------> >>>-- Mojave Project -- http://mojave.cs.caltech.edu -->