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 IAA24850; Thu, 24 Oct 2002 08:59:17 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id IAA24969 for ; Thu, 24 Oct 2002 08:59:16 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from athlon.baretta.com ([62.211.4.209]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g9O6xF515145 for ; Thu, 24 Oct 2002 08:59:15 +0200 (MET DST) Received: from baretta.com (localhost.localdomain [127.0.0.1]) by athlon.baretta.com (Postfix) with ESMTP id CCC3027250 for ; Thu, 24 Oct 2002 09:10:15 +0200 (CEST) Message-ID: <3DB79CD7.6040600@baretta.com> Date: Thu, 24 Oct 2002 09:10:15 +0200 From: Alessandro Baretta Organization: Baretta srl -- www.baretta.com User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826 X-Accept-Language: it, en MIME-Version: 1.0 To: Ocaml Subject: Re: [Caml-list] Again on pattern matching and strings References: <3DB73515.90705@baretta.com> <20021023235719.GA9170@cs.unibo.it> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Stefano Zacchiroli wrote: > On Thu, Oct 24, 2002 at 01:47:33AM +0200, Alessandro Baretta wrote: > >>| Some ( "\027(U\001\000\005" ) -> ... >>| Some ( "\027@" ) -> ... >>| Some ( "\012" ) -> ... > > > What about: > > | Some m when m = printer_set_unit -> ... > | Some m when m = printer-reset -> ... > | Some m when m = printer_formfeed -> ... > ... > | Some (_) -> assert false > | None -> () > > It isn't so bad ... Eh, no! This is really unacceptable as a general solution. Of course, I could have coded my function this way, but this technique is not scalable, especially from the perspective of computational efficiency. Your code is compiled as a sequence of comparisons on a strings. Hence, the matched string is scanned once for every pattern. With constant patterns, on the other hand, the compiler should scan the string only once and jump to appropriate code. This is more compact, but not necessarily more efficient, as Jacques pointed out a while ago. ( http://caml.inria.fr/archives/200101/msg00111.html ) > Anyway from a more general point of view I'm also interested in seeing > "aliasing" or constant definition in the compiler, it is of general > interest, not only in pattern matching. To my great surprise, I'm unable to think of an example relating to anything other than pattern matching. Alex ------------------- 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