From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 801A2BBAF for ; Tue, 4 May 2010 12:48:45 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aq4CALaY30uBrw8EnGdsb2JhbACGfZVaWhUBAQEBAQgLCAkRIrs0hRME X-IronPort-AV: E=Sophos;i="4.52,325,1270418400"; d="scan'208";a="49910115" Received: from ext.lri.fr ([129.175.15.4]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 04 May 2010 12:48:36 +0200 Received: from localhost (localhost [127.0.0.1]) by ext.lri.fr (Postfix) with ESMTP id 3B767A46C8 for ; Tue, 4 May 2010 12:48:31 +0200 (CEST) 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 eu6xNrDm62VJ for ; Tue, 4 May 2010 12:48:31 +0200 (CEST) Received: from Sedrikov.home (ASte-Genev-Bois-154-1-22-74.w81-249.abo.wanadoo.fr [81.249.181.74]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by ext.lri.fr (Postfix) with ESMTP id D7D77A46A9 for ; Tue, 4 May 2010 12:48:30 +0200 (CEST) Date: Tue, 4 May 2010 12:33:58 +0200 From: AUGER =?ISO-8859-1?B?Q+lkcmlj?= Cc: caml-list@inria.fr Subject: Re: [Caml-list] Re: Subtyping structurally-equivalent records, or something like it? Message-ID: <20100504123358.01c98f72cauger@lri.fr@Sedrikov.home> In-Reply-To: References: <602616.65342.qm@web111501.mail.gq1.yahoo.com> X-Mailer: Claws Mail 3.7.5 (GTK+ 2.18.9; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; lri:01 subtyping:01 ocaml:01 compiler:01 caml-list:01 functions:01 constructor:01 constructor:01 match:02 let:03 overhead:04 overhead:04 optimized:04 types:05 types:05 I am not expert in Ocaml, is the following the same in terms of performances as the phantom types? type kinematic = ... type force = Force of kinematic type momentum = Moment of kinematic ... That is does the constructor introduce an overhead or not? As there is only one constructor, no overhead should be done in an optimized compiler. So general functions should use a kinematic -> [Type] and a specialized function, force -> [Type] and so on... I understand this version is not as handy as the phantom types, as we need to use "match ... with Force f -> ..." or at least "let Force f = ... in ...", but my question is only in terms of efficiency; obviously phantom types are more or equally efficient than what I exposed, but does the reciproque also holds?