From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 62CC1BB91 for ; Sun, 23 Jan 2005 22:48:09 +0100 (CET) Received: from ptb-relay03.plus.net (ptb-relay03.plus.net [212.159.14.214]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j0NLm8um008708 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 23 Jan 2005 22:48:09 +0100 Received: from [80.229.56.224] (helo=chetara) by ptb-relay03.plus.net with esmtp (Exim) id 1CspsI-000Dho-2y for caml-list@yquem.inria.fr; Sun, 23 Jan 2005 22:06:26 +0000 From: Jon Harrop Organization: University of Cambridge To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Strange syntax error Date: Sun, 23 Jan 2005 21:49:54 +0000 User-Agent: KMail/1.7.1 References: <20050123211112.GA14067@furbychan.cocan.org> In-Reply-To: <20050123211112.GA14067@furbychan.cocan.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200501232149.54437.jon@jdh30.plus.com> X-Miltered: at concorde with ID 41F41B98.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 syntax:01 wrote:01 parsing:01 bug:01 failwith:01 failwith:01 cheers:01 ...:98 inefficient:01 patterns:02 tree:02 guess:02 clause:03 pattern:03 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: On Sunday 23 January 2005 21:11, Richard Jones wrote: > ... > Is this a parsing bug? I assume a "when" clause is only allowed at the end of the list of alternative patterns. For example: let f = function { keyword = keyword } -> keyword | { keyword = keyword; cost = None } when keyword.[0] = '-' -> keyword | _ -> failwith "whatever" is allowed (but not what you wanted). I guess that allowing "when" clauses on each alternative pattern would obviate the advantages of using a decision tree to represent pattern matching and, therefore, would make pattern matches significantly more inefficient. Hence they don't do it. In this case, I'd go for: let f = function { keyword = keyword } when keyword.[0] = '-' -> keyword | { cost = None } as t -> t.keyword | _ -> failwith "whatever" Say, this wouldn't be related to that arg-passing problem would it? ;-) Cheers, Jon.