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 TAA15803; Tue, 29 May 2001 19:18:09 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA15502 for caml-list@pauillac.inria.fr; Tue, 29 May 2001 19:18:08 +0200 (MET DST) 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 TAA15786 for ; Tue, 29 May 2001 19:17:08 +0200 (MET DST) Received: from localhost.localdomain (kenny41.zip.com.au [61.8.18.169]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f4THH5D28498 for ; Tue, 29 May 2001 19:17:06 +0200 (MET DST) Received: from ozemail.com.au (IDENT:root@localhost [127.0.0.1]) by localhost.localdomain (8.9.3/8.8.7) with ESMTP id DAA21321; Wed, 30 May 2001 03:16:52 +1000 Message-ID: <3B13D984.A8CAF922@ozemail.com.au> Date: Wed, 30 May 2001 03:16:52 +1000 From: John Max Skaller X-Mailer: Mozilla 4.7 [en] (X11; I; Linux 2.2.12-20 i686) X-Accept-Language: en MIME-Version: 1.0 To: Andreas Rossberg CC: caml-list@inria.fr Subject: Re: [Caml-list] ocaml and named constants References: <20010528143238.D19801@pauillac.inria.fr> <3B12F66C.5F5793F9@ozemail.com.au> <3B139236.C2B435F0@ps.uni-sb.de> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Andreas Rossberg wrote: > > Is there any semantic reason why > > one cannot use variables, or even expressions? Apart from > > the obvious syntactic problem. > > If you allow arbitrary (dynamically determined) values to be matched > against, then pattern matching has unbound cost. > OTOH, with the current > form, the cost of pattern matching is always linear in the syntactic > size of the match. Unless you use a 'when' construct .. which already provides what I was asking for. The case when this is most annoying is for 'manifest constants': let c1 = 1 and c2 = 2 in match expr with | x when x = c1 -> .. | x when x = c2 -> .. where the 'match' construction is still arguably cleaner than an if/then/else chain let x = expr in if x = c1 then .. else if x = c2 then .. especially if you're actually matching as well: match expr with | (x,y) when x = c1 -> ... -- John (Max) Skaller, mailto:skaller@maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850 checkout Vyper http://Vyper.sourceforge.net download Interscript http://Interscript.sourceforge.net ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr