From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA08953; Thu, 24 Oct 2002 18:26:32 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA08568 for ; Thu, 24 Oct 2002 18:26:31 +0200 (MET DST) Received: from mel-rto2.wanadoo.fr (smtp-out-2.wanadoo.fr [193.252.19.254]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g9OGQVD17915; Thu, 24 Oct 2002 18:26:31 +0200 (MET DST) Received: from mel-rta9.wanadoo.fr (193.252.19.69) by mel-rto2.wanadoo.fr (6.5.007) id 3DA24CF600AA12E1; Thu, 24 Oct 2002 18:26:30 +0200 Received: from iliana (81.48.94.93) by mel-rta9.wanadoo.fr (6.5.007) id 3DA24B2900AFF77B; Thu, 24 Oct 2002 18:26:30 +0200 Received: from luther by iliana with local (Exim 3.36 #1 (Debian)) id 184koX-00019T-00; Thu, 24 Oct 2002 18:26:29 +0200 Date: Thu, 24 Oct 2002 18:26:29 +0200 To: Luc Maranget Cc: Alessandro Baretta , Jacques Garrigue , Ocaml Subject: Re: [Caml-list] Again on pattern matching and strings Message-ID: <20021024162629.GA4395@iliana> References: <3DB7E9B5.8020406@baretta.com> <200210241324.PAA0000015374@beaune.inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200210241324.PAA0000015374@beaune.inria.fr> User-Agent: Mutt/1.4i From: Sven Luther Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, Oct 24, 2002 at 03:24:26PM +0200, Luc Maranget wrote: > > > > > > > > Jacques Garrigue wrote: > > > > > That message was about polymorphic variants, which are encoded as > > > integers, and for which pattern-matching is a decision tree. > > > > > > However, if you look in bytecomp/matching.ml, you will see that string > > > patterns are just checked sequentially (the ordering is not used). > > > Moreover, the match compiler seems to be clever enough to compile > > > properly the above style:... > > > > Very strange. I thought the Ocaml compiler sould > > precalculate the branch of pattern matching to be taken, and > > then jump, thereby avoiding sequential checking. I'm sorry > > for my mistake. > > If you are interested in pm code, I would suggest that you have a look > at the produced code after pattern-matching compilation (option -dlambda), > before looking at the compiler sources. > > The issue is not really PM bu rather switches: how to compile > a serche in a ordered list of constants ? > > To sum it up for strings : strings are atoms to the PM compiler which > never look into them, it only compares one string against another, for > equality only. The match compiler does not make avantage of the known > pattern string in any sense. The match compiler does not make > avantage of the existence of a lexical ordering on strings. In fact > many << optimizations >> are posible here, none is performed. So, i suppose replacing all strings in a pattern matching by an integer pointing to hashtable or something would improve performance a lot if the same string is pattern matched over and over again ? Friendly, Sven Luther ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners