Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Caml historical question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <xavier.leroy@i...>
Subject: Re: [Caml-list] Caml historical question
> OK Caml history buffs, I have a question which arose during my
> proofreading of a chapter of the forthcoming bestseller "Developing
> Applications with Objective Caml" (Stephen King, watch out!).
> In the current translation, it is mentioned that "fun" is a legacy of
> older versions of Caml and it is insinuated that the "fun" form is somehow
> deprecated in favor of fun. What's the straight dope?

I wouldn't say that either "fun" or "function" is deprecated in favor
of the other.  Basically, we have "fun" for multiple-arguments,
one-case definitions:
        fun pat1 ... patN -> expr
and "function" for single-argument, multiple-case definitions:
        function pat1 -> expr1
               | ...
               | patN -> exprN
Both seem equally useful, although there is admittedly some overlap
between the two forms.

What is deprecated in OCaml, but was supported in Caml Light and Caml V3.1,
is multiple-case "fun":
        fun pat11 ... patN1 -> expr1
          | ...
          | pat1M ... patNM -> exprM
Although this form subsumes the previous two, the extra generality was
rarely useful, and complex patterns have to be parenthesized so that
the parser can figure them out.

- Xavier Leroy
Bug reports:  FAQ:
To unsubscribe, mail  Archives: