Re: convincing management to switch to Ocaml

From: John Skaller (
Date: Tue Aug 31 1999 - 07:19:48 MET DST

Message-Id: <>
Date: Tue, 31 Aug 1999 15:19:48 +1000
To: John Prevost <>, Pierre Weis <>
From: John Skaller <>
Subject: Re: convincing management to switch to Ocaml
In-Reply-To: <>

At 20:13 30/08/99 -0400, John Prevost wrote:
>Pierre Weis <> writes:

>I had a similar problem with SML and Caml until I realized the one
>important rule that makes things clear: The juxtaposition
>(application) operator has the highest precedence.

Actually, I don't have much problem remembering that one,
since it is used so often. However, let me give
you an example I cannot do today. I tried various
combinations, and have given up in exasperation. :-)
Consider that I wish to add some optional types to:

        let f x y = something;;

Now I know I can write

        let f (x:t1) (y:t2) : t3 = something;;

and I can write

        let f: t2 -> t2 -> t3 = something;;

but the latter doesn't work right if I need the parameters
to have names. I tried:

        let (f: t2 -> t2 -> t3) x y = something;;

and that doesn't seem to work? This shape is important,
where I have a set of functions of the same type,
with an abbreviation. There seems to be a problem,
that the operator -> is overloaded in meaning:
it means 'returns the type' and also 'has the value'.
So in

        fun x y -> value

I cannot just write

        fun x y : t1 -> t2 -> value

because the -> would be ambiguous, and I'm at a loss to know
where the brackets should go, or even if it is possible
to type the result of this function or the type of the return
value. In fact, with currying, it isn't quite so clear
what 'return value' means, since it depends on
whether you apply the return value again.

Now, I am sure the answers lie in the formal grammar, but the
(informal) grammar in the manual
is too complex to comprehend, and doesn't specify semantics,
(except some curoty notes), and the various 'precedence tables'
floating around don't seem to cover all the cases: I usually
use the 'ocaml' interpreter to answer these kinds of questions
by trial and error.

John Skaller email:
                phone: 61-2-96600850
                snail: 10/1 Toxteth Rd, Glebe NSW 2037, Australia

This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:25 MET