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
Re: convincing management to switch to Ocaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1999-08-31 (17:15)
From: John Skaller <skaller@m...>
Subject: Re: convincing management to switch to Ocaml
At 20:13 30/08/99 -0400, John Prevost wrote:
>Pierre Weis <Pierre.Weis@inria.fr> 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: skaller@maxtal.com.au
		phone: 61-2-96600850
		snail: 10/1 Toxteth Rd, Glebe NSW 2037, Australia