From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id EAA32490; Thu, 22 Aug 2002 04:32:50 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id EAA02601 for ; Thu, 22 Aug 2002 04:32:49 +0200 (MET DST) Received: from corwin.mutu.net (mutu.net [80.65.226.162]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g7M2Wl900664 for ; Thu, 22 Aug 2002 04:32:48 +0200 (MET DST) Received: by corwin.mutu.net (Postfix, from userid 1000) id 2537F15901E; Thu, 22 Aug 2002 04:32:07 +0200 (CEST) To: Pal-Kristian Engstad Cc: Oleg , Oliver Bandel , caml-list@inria.fr Subject: Re: [Caml-list] Calling a function with a self-defined type as argument References: <200208220149.VAA14728@dewberry.cc.columbia.edu> <200208211920.09550.engstad@naughtydog.com> X-face: '|!UPdE>Ot'L}nt?6Tf|'s{y%l~,+Yc5|p8A}ibew|_!vc48pPNPPx@7QA~$`$g=|yH*8sh9R]Xj1(CV7oUe>#/,t.(Z4F From: Dimitri Ara Date: 22 Aug 2002 04:32:07 +0200 In-Reply-To: <200208211920.09550.engstad@naughtydog.com> Message-ID: <87ptwby66w.fsf@corwin.mutu.net> User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Pal-Kristian Engstad a écrit : > Hi, > > I don't know if it is in the FAQ, but a more interesting question is why the > compiler cannot deduce the correct type without us having to type in > parenthesis, at least in cases where there can be no ambiguity. > > I.e.: > > let addone x = x + 1 > let double x = x * x > > let f x = addone double x (*** Should the compiler not deduce this? ***) > let g = addone double (*** Is this why? ***) In the general case it can't: # let f g x = x;; val f : 'a -> 'b -> 'b = # let h x = x;; val h : 'a -> 'a = # (f h) 1;; - : int = 1 # f (h 1);; - : '_a -> '_a = When there is no ambiguity it could but it would be expensive, dangerous (because the compiler could find a way to type an expression which is ill typed according to what you meant) and would make the sources unreadable. ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners