Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] function vs. parser
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Daniel de Rauglaudre <daniel.de_rauglaudre@i...>
Subject: Re: [Caml-list] function vs. parser
Hi,

On Thu, Sep 13, 2001 at 05:20:11PM +0900, SooHyoung Oh wrote:

> Could anyone explain me why "parser" was introduced in Ocaml?
> As you know, "function" is using in the caml light-instead of "parser".
> "parser" must be a reserved word like "let" and "function", right?

Right: "parser" is used because they are not functions. In Caml Light,
we used "function", but it was an bad idea: the pattern matching rules
in parsers have nothing to do with the pattern matching rules in
functions and it was important to separate the notions.

Another reason is that in OCaml, after "parser" (and after the streams
patterns), you can put a pattern to bind the current stream count:

    parser bp
      [< .... >] ep -> (* bp: stream count before the matching;
                          ep: stream count after the matching *)
    | [< .... >] ep -> (* same... *)
    | ...

With "function", the language would be more complicated to parse.

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr