From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr 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 B9548BB9C for ; Wed, 23 Nov 2005 15:47:37 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jANElb4E024733 for ; Wed, 23 Nov 2005 15:47:37 +0100 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 PAA05217 for ; Wed, 23 Nov 2005 15:47:36 +0100 (MET) Received: from net.univ-savoie.fr (net.univ-savoie.fr [193.48.120.75]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jANElaCg024728 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Wed, 23 Nov 2005 15:47:36 +0100 Received: from post.bourget.univ-savoie.fr (post.bourget.univ-savoie.fr [193.48.120.73]) by net.univ-savoie.fr (8.12.3/jtpda-5.4) with ESMTP id jANElXeo021344 ; Wed, 23 Nov 2005 15:47:33 +0100 Received: from [193.48.123.45] (d45.lama.univ-savoie.fr [193.48.123.45]) by post.bourget.univ-savoie.fr (8.12.3/jtpda-5.4) with ESMTP id jANElQQb022206 ; Wed, 23 Nov 2005 15:47:27 +0100 Message-ID: <43848103.9060504@univ-savoie.fr> Date: Wed, 23 Nov 2005 15:47:31 +0100 From: Christophe Raffalli User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) X-Accept-Language: fr, en MIME-Version: 1.0 To: sejourne_kevin Cc: caml-list Subject: Re: [Caml-list] Request for complete pattern matching References: <43839F1A.2080909@univ-savoie.fr> <43842069.3070700@yahoo.fr> In-Reply-To: <43842069.3070700@yahoo.fr> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.33 (www . roaringpenguin . com / mimedefang) X-Miltered: at concorde with ID 43848109.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 43848108.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; christophe:01 raffalli:01 christophe:01 raffalli:01 univ-savoie:01 caml-list:01 lazy:01 lazy:01 camlp:01 expr:01 expr:01 syntax:01 compiler:01 ocaml:01 camlp:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 sejourne_kevin a écrit : > Christophe Raffalli a écrit : > >> - Lazy constructor and function can not be matched ... and this is >> ennoying >> >> I saw a post recently about lazy constructor and I can not write the >> camlp4 extension I want because of the second limitation ... >> >> It may be not clear what I mean by matching a function (looks impossible >> ;-). I mean something like >> >> pattern <= expr expr expr is a pattern >> >> and a function f is matched by >> >> p <= e1 ... eN iff f e1 ... eN is matched by p >> >> (I do not care about the final syntax ...) >> > > You want something like that ? > > let f = function > (x,y,z) when f x y z -> ... > | (x,y,z) when g x y z -> ... > | all_other_cases -> (static/compile_time)_error ... > No this is not a problem of test. I want to be able to write match e with (0 <= 0, g) -> g | (f, 0 <= 0) -> f | (f, g) -> fun x -> f x + g x which means the same as match e with (f, g) -> if f 0 = 0 then g else if g 0 = 0 then f else fun x -> f x + g x - The first problem is that removing this feature is a hard translation, and I would like the compiler to do it - The second problem is that I really need it to extend the pattern matching of ocaml using camlp4 Let us do a simple example (this is not what I am doing): type 'a lazy = unit -> 'a Lazy(e) := fun () -> e (defined as a camlp4 macro to be sure that e is not evaluated) and then "Lazy(p)" in a pattern means "p <= ()" (this should also be a camlp4 macro, but p <= () does not exist in the language) > Should be hard to eval f and g before execution... > > > > > > > Kévin. > > > > > > ___________________________________________________________________________ > Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! > Messenger Téléchargez cette version sur http://fr.messenger.yahoo.com > -- Christophe Raffalli Université de Savoie Batiment Le Chablais, bureau 21 73376 Le Bourget-du-Lac Cedex tél: (33) 4 79 75 81 03 fax: (33) 4 79 75 87 42 mail: Christophe.Raffalli@univ-savoie.fr www: http://www.lama.univ-savoie.fr/~RAFFALLI --------------------------------------------- IMPORTANT: this mail is signed using PGP/MIME At least Enigmail/Mozilla, mutt or evolution can check this signature. The public key is stored on www.keyserver.net ---------------------------------------------