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 RAA04196; Wed, 10 Dec 2003 17:54:10 +0100 (MET) 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 RAA02513 for ; Wed, 10 Dec 2003 17:54:09 +0100 (MET) Received: from mail3.tpgi.com.au (mail.tpgi.com.au [203.12.160.59]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id hBAGs6104643; Wed, 10 Dec 2003 17:54:07 +0100 (MET) Received: from 203-213-85-203-syd-ts17-2600.tpgi.com.au (203-213-85-203-syd-ts17-2600.tpgi.com.au [203.213.85.203]) by mail3.tpgi.com.au (8.11.6/8.11.6) with ESMTP id hBAGs2U02500; Thu, 11 Dec 2003 03:54:03 +1100 Subject: Re: [Caml-list] Question From: skaller Reply-To: skaller@ozemail.com.au To: Pierre Weis Cc: caml-list In-Reply-To: <200312101027.LAA20728@pauillac.inria.fr> References: <200312101027.LAA20728@pauillac.inria.fr> Content-Type: text/plain Message-Id: <1071071631.4023.16.camel@pelican> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 11 Dec 2003 02:53:51 +1100 Content-Transfer-Encoding: 7bit X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 ozemail:01 pierre:01 weis:01 ocaml's:01 invariants:01 runtime:01 slower:01 compiler:01 semantics:01 wrt:01 wrt:01 behaviour:01 complexity:02 match:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, 2003-12-10 at 21:27, Pierre Weis wrote: > [...] > > I was expecting "when" to be right distributive over "|". I find > > OCaml's behaviour not very intuitive in such a situation. > [...] > > The when construct introduces a guard to a pattern matching > clause. This means that a when construct is global to the entire > pattern of the clause it appears in; it means in particular that no > when construct can be nested into a pattern and the question of its > distributivity wrt any other construct is pointless. > > > Is there a good reason for this? > > Yes: simplicity, complexity invariants preservation for runtime > pattern analysis decisions even in the presence of when clauses, > easier understanding of the compiler warnings, simplicity and > well-definedness semantics (in particular the desired invariance wrt > the order of evaluation). Whoa! Can you say that slower? Felix allows nested when clauses in patterns (however it doesn't allow alternatives yet). The current implementation is unoptimised, I just evaluate the match of each pattern in turn until one matches. One small difference .. the argument of a when clause is an expression .. and felix expressions are purely functional so there is no issue of order of evaluation changing anything. So, what have I lost? ------------------- 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