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 AAA28200; Tue, 6 Apr 2004 00:52:41 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 AAA28175 for ; Tue, 6 Apr 2004 00:52:40 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from web40613.mail.yahoo.com (web40613.mail.yahoo.com [66.218.78.150]) by nez-perce.inria.fr (8.12.10/8.12.10) with SMTP id i35MrTjq013452 for ; Tue, 6 Apr 2004 00:53:30 +0200 Message-ID: <20040405225238.33087.qmail@web40613.mail.yahoo.com> Received: from [65.57.245.11] by web40613.mail.yahoo.com via HTTP; Mon, 05 Apr 2004 15:52:38 PDT Date: Mon, 5 Apr 2004 15:52:38 -0700 (PDT) From: Ker Lutyn Subject: Re: [Caml-list] failwith, raise and type inference To: Pierre Weis , Luc Maranget Cc: pguyot@kallisys.net, caml-list@inria.fr In-Reply-To: <200404022028.WAA20083@pauillac.inria.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Miltered: at nez-perce by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 failwith:01 inference:01 haskell's:01 failwith:01 foo:01 haskell's:01 pierre:01 weis:01 pierre:01 weis:01 logics:01 logics:01 parentheses:01 bug:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Status: X-Keywords: X-UID: 54 I wonder if we could have Haskell's $ operator added to OCaml. It would make this idiom and a lot of my code nicer. failwith $ "foo" ^ "bar" Defining it myself as let ($) f x = f x doesn't work because of precedence and associativity. The caml sources frequently define let (++) x f = f x which is a similar idea - but lots of times Haskell's $ is what you want. --- Pierre Weis wrote: > [...] > > Admitedly caml syntax is not very beginner friendly. > > But the observed parsing has some internal logics. > > > > On usualy understand that f x + y is in fact (f x) + y > > But here, with failwith being a ``special'' function and ^ a ``special'' > > operator, well... > > That could be part of the problem: failwith is not ``special'' nor is ^, > hence the regular treatment of f x ^ y as (f x) ^ y and failwith x ^ y > as (failwith x) ^ y. > > Operator precedence in Caml has been carefully crafted, you should > have a look at the programming guide lines that gives some hints on the > internal logics of some parts of the parsing, in the section > > When to use parentheses within an expression > > Best regards, > > Pierre Weis > > INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/ > > > ------------------- > 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 __________________________________ Do you Yahoo!? Yahoo! Small Business $15K Web Design Giveaway http://promotions.yahoo.com/design_giveaway/ ------------------- 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