From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA30095 for caml-redistribution; Tue, 31 Aug 1999 19:15:13 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id IAA07310 for ; Tue, 31 Aug 1999 08:20:42 +0200 (MET DST) Received: from iggy.triode.net.au (iggy.triode.net.au [203.63.235.1]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id IAA18817; Tue, 31 Aug 1999 08:20:38 +0200 (MET DST) Received: from egret (pm1-2.triode.net.au [203.63.235.18]) by iggy.triode.net.au (8.9.3/8.8.8) with SMTP id QAA11823; Tue, 31 Aug 1999 16:18:10 +1000 Message-Id: <3.0.6.32.19990831151948.00971280@mail.triode.net.au> X-Sender: skaller@mail.triode.net.au X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.6 (32) 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 Cc: caml-list@inria.fr In-Reply-To: References: <199908300802.KAA15269@pauillac.inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Sender: weis 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: skaller@maxtal.com.au http://www.maxtal.com.au/~skaller phone: 61-2-96600850 snail: 10/1 Toxteth Rd, Glebe NSW 2037, Australia