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 PAA13990; Thu, 22 Aug 2002 15:59:51 +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 PAA13906 for ; Thu, 22 Aug 2002 15:59:50 +0200 (MET DST) Received: from mel-rto6.wanadoo.fr (smtp-out-6.wanadoo.fr [193.252.19.25]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g7MDxoX22065 for ; Thu, 22 Aug 2002 15:59:50 +0200 (MET DST) Received: from mel-rta8.wanadoo.fr (193.252.19.79) by mel-rto6.wanadoo.fr (6.5.007) id 3D6246E8000DCE44; Thu, 22 Aug 2002 15:59:38 +0200 Received: from iliana (80.9.104.38) by mel-rta8.wanadoo.fr (6.5.007) id 3D49FF79006FE221; Thu, 22 Aug 2002 15:59:38 +0200 Received: from luther by iliana with local (Exim 3.35 #1 (Debian)) id 17hrlx-0003lu-00; Thu, 22 Aug 2002 15:13:13 +0200 Date: Thu, 22 Aug 2002 15:13:13 +0200 To: Oliver Bandel Cc: Dimitri Ara , caml-list@inria.fr Subject: Re: [Caml-list] Calling a function with a self-defined type as argument Message-ID: <20020822131313.GA14497@iliana> References: <87y9azy7h3.fsf@corwin.mutu.net> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.4i From: Sven LUTHER Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, Aug 22, 2002 at 02:47:26PM +0200, Oliver Bandel wrote: > > On 22 Aug 2002, Dimitri Ara wrote: > > > Oliver Bandel a écrit : > > > > > (* > > > let _ = x Line "h0oifdaji oi" ;; > > > This last one does not work: => "This function is applied to too many arguments" > > > > > > let _ = x Line( "reuruhjf" ) ;; > > > This last one does not work: => "This function is applied to too many arguments" > > > > > > But it works in this way: > > > let _ = x (Line "reuruhjf") ;; > > > > > > WHY? (why *only* that?) > > > > > > At least the second example (with parantheses around the > > > Line's arguments) should work...?! > > > *) > > > > Because : > > > > (1) application is left associative. > > > > Thus `f x y' means `(f x) y' and > > `x Line ""' means `(x Line) ""'. > > > > (2) parentheses don't delimit the arguments of a function or a > > constructor but only fix the precedence of an expression. > > > > Thus f x (y) means f x y and > > `x Line ("")' means `x Line ""'. > > OK. > But why has the Line()-argument not a higher pruiority than the > function-call? > The Line()-argument is only complete, if it get's it's > args. And the type-declaration says in detail, how to > handle the Line(). No, in ocaml, the function application is the space ' ', so what you are used to write "f(x)", is just plain "f x", and you can add a few ( to make unambigous, as in your case : (f x). It seems confusing if you are not used to it, but makes for more clearer code. Friendly, Sven Luther ------------------- 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