From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id EB11DBC57 for ; Tue, 8 Jun 2010 11:45:28 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AoMCAHKuDUxRZ90xkWdsb2JhbACSL4wSFQEBAQEJCwoHEQMfvRaFFgQ X-IronPort-AV: E=Sophos;i="4.53,383,1272837600"; d="scan'208";a="52656949" Received: from mtaout03-winn.ispmail.ntl.com ([81.103.221.49]) by mail2-smtp-roc.national.inria.fr with ESMTP; 08 Jun 2010 11:45:28 +0200 Received: from aamtaout02-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout03-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20100608094524.RNZN3075.mtaout03-winn.ispmail.ntl.com@aamtaout02-winn.ispmail.ntl.com>; Tue, 8 Jun 2010 10:45:24 +0100 Received: from romulus.metastack.com ([81.102.132.77]) by aamtaout02-winn.ispmail.ntl.com (InterMail vG.2.02.00.01 201-2161-120-102-20060912) with ESMTP id <20100608094524.TLAO1586.aamtaout02-winn.ispmail.ntl.com@romulus.metastack.com>; Tue, 8 Jun 2010 10:45:24 +0100 Received: from Tenor ([172.16.0.8]) (authenticated bits=0) by romulus.metastack.com (8.14.2/8.14.2) with ESMTP id o589jKhn010704 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Tue, 8 Jun 2010 10:45:21 +0100 From: "David Allsopp" To: Cc: "'bluestorm'" , , "'W Dan Meyer'" References: <4C0D3557.1020200@gmail.com> <010d01cb0672$09f3eb90$1ddbc2b0$@romulus.metastack.com> <4C0D4C88.4070102@gmail.com> <877hma78xf.fsf@gmail.com> <013a01cb06de$32c6d930$98548b90$@romulus.metastack.com> <015201cb06ea$f06adc00$d1409400$@romulus.metastack.com> <20100608093651.GA8296@yquem.inria.fr> In-Reply-To: <20100608093651.GA8296@yquem.inria.fr> Subject: RE: [Caml-list] Converting variants with only constant constructors to integers Date: Tue, 8 Jun 2010 10:45:20 +0100 Message-ID: <015f01cb06ef$500b4f60$f021ee20$@romulus.metastack.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQK3OCAoaAveGworypJxQY6jcfYL4QG5R1OKAl4LCCQB8HFXWwG5f4A0AZ1ERFMCOcHmgwHorL8MAgkoyREB2kERuA== Content-Language: en-gb Organization: MetaStack Solutions Ltd. X-Scanned-By: MIMEDefang 2.65 on 81.102.132.77 X-Cloudmark-Analysis: v=1.1 cv=W3tOLUehizD4qj6VhtReFuw5MKb8d+XqjIxlDsIazEA= c=1 sm=0 a=dfm47NNIjPMA:10 a=VZGMvYHv9TIA:10 a=8sW17jYxVu0A:10 a=kj9zAlcOel0A:10 a=SAy_ccAE9VQLMDsATXQA:9 a=HbfpX9-7MfZ8Uj-Efbn-H0cP7KIA:4 a=CjuIK1q_8ugA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 X-Spam: no; 0.00; variants:01 constructors:01 integers:01 maranget:01 compiler:01 hashtable:01 compiler:01 lookup':01 dreamt:98 wrote:01 luc:01 caml-list:01 int:01 let:03 converting:05 Luc Maranget wrote: > Of course, if you have the following: > > > > type t = A | B | C > > let int_of_t = function > > A -> 0 > > | B -> 1 > > | C -> 2 > > > > Then in fact I believe that the compiler already converts that to a > > hashtable lookup instead of a sequence of jumps.. > > The compiler does not convert the above code to 'hashtable lookup'. Is there a point where the compiler does do a table lookup for matches rather than jumps or have I clearly just dreamt that? :o) David