From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 37F5DBC88 for ; Fri, 4 Feb 2005 22:30:05 +0100 (CET) Received: from first.in-berlin.de (dialin-145-254-053-157.arcor-ip.net [145.254.53.157]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j14LU3G0016849 for ; Fri, 4 Feb 2005 22:30:04 +0100 Received: by first.in-berlin.de (Postfix, from userid 501) id 16AC2A7631; Fri, 4 Feb 2005 19:46:02 +0100 (CET) Date: Fri, 4 Feb 2005 19:46:02 +0100 From: Oliver Bandel To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Estimating the size of the ocaml community Message-ID: <20050204184602.GA897@first.in-berlin.de> References: <891bd33905020213315a2ebb18@mail.gmail.com> <009a01c50a1e$f6c92080$0100a8c0@mshome.net> <200502040233.40444.jon@jdh30.plus.com> <20050204094129.GB15155@furbychan.cocan.org> <20050204160023.GE498@first.in-berlin.de> <4203B190.9090909@yahoo.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4203B190.9090909@yahoo.fr> User-Agent: Mutt/1.5.6i X-Miltered: at concorde with ID 4203E95B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; oliver:01 bandel:01 oliver:01 in-berlin:01 caml-list:01 ocaml:01 wrote:01 bandel:01 printf:01 printf:01 failwith:01 unification:01 failwith:01 unification:01 haskell's:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.2 X-Spam-Level: On Fri, Feb 04, 2005 at 06:32:00PM +0100, sejourne_kevin wrote: > Oliver Bandel a écrit : > >9.: Pattern matching, that *really* is functional (seems to be necessary > >that it works > > like it is done in logical programming languages like Prolog or > > similar? > > Something like this could be fun (just like Prolog): > > (*caml way*) > let test = function > [(1,a);b;(3,c);(4,d)] ->Printf.printf "%d %d %d \n" a c d; b > | _ -> failwith "Unification Impossible" > ;; > (*half-prolog way*) > let test [(1,a);b;(3,c);(4,d)] = Printf.printf "%d %d %d \n" a c d; b > and test _ = failwith "Unification Impossible" > ;; The second one ("half-prolog way") looks a littlebid like Haskell's syntax. What I mean is, that your (*caml way*) let test = function [(1,a);b;(3,c);(4,d)] ->Printf.printf "%d %d %d \n" a c d; b | _ -> failwith "Unification Impossible" ;; would work equally for all input data, if written in the opposite order of pattern-match code-lines: (*caml way*) let test = function _ -> failwith "Unification Impossible" | [(1,a);b;(3,c);(4,d)] ->Printf.printf "%d %d %d \n" a c d; b ;; And this, because in a functional setting it does not matter, which expression comes first: it's always the same result for the same input data, independent of the order of lines of code. Now (but in Haskell it's the same) it is NOT independent of which comes first. This was a mayjor problem of understanding Pattern Matches, especially because all people said (in books and papers too!) that pattern matching belongs to the functional world. I now can use OCaml pattern matches without problems, but in the first time I was very annoyed about saying that this is a functional language feature, when it really not is. So, maybe the documentation and the papers and books should not call it functional pattern matching, but pattern matching (or imperative pattern matching). As OCaml has in it's concept that it also uses OO-features and imperative features, there is no problem for me to accept the pattern matching features as they are now. But I like it to say it, how it is (not, how people want to show it, even if it is differently). And IMHO such a lmatch (logical match) or fmatch (functional match) should be added to the OCaml-Core. (If possible.) [...] > With a logic match, Ocaml could be functionnal, imperative, object and > logic. Yes, that's fine. :) I think only Oz can compete here (but as far as I know it is not as efficient/performant as OCaml). > Just need a dynamic syntax to have the power of Prolog with the > power of OCaml... cool. The problem with the logic > match (* | "prefix"^str -> *) is that ^ isn't a constructor but a > function. I think, the logic match can't be determinist. IHMO, Prolog > can do it just because all data are term(s) as all 'function'. Hmhhh, so you think there are theoretical problems to implement such thing?! Ciao, Oliver