English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2001-09-13 (08:48)
From: Daniel de Rauglaudre <daniel.de_rauglaudre@i...>
Subject: Re: [Caml-list] function vs. parser

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.

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