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 HAA09952; Tue, 11 May 2004 07:13:06 +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 HAA09056 for ; Tue, 11 May 2004 07:13:05 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i4B5D0EV011616 for ; Tue, 11 May 2004 07:13:04 +0200 Received: from localhost (suiren.kurims.kyoto-u.ac.jp [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.9.3p2-20030924/3.7W) with ESMTP id OAA08321; Tue, 11 May 2004 14:12:54 +0900 (JST) Date: Tue, 11 May 2004 07:12:59 +0200 (CEST) Message-Id: <20040511.071259.74751201.garrigue@kurims.kyoto-u.ac.jp> To: er+caml@cs.brown.edu, er@cs.brown.edu Cc: caml-list@inria.fr Subject: Re: [Caml-list] Total application of function with labels From: Jacques Garrigue In-Reply-To: <20040505211822.GA23376@cs.brown.edu> References: <20040505211822.GA23376@cs.brown.edu> X-Mailer: Mew version 4.0.64 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 40A060DC.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 jacques:01 renieris:01 bug:01 passing:01 bug:01 labeling:01 val:01 omitted:01 jacques:01 wwwfun:01 ocaml:01 int:01 int:01 garrigue:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: Manos Renieris > Total applications of functions with labeled arguments will work, > even if the actual arguments have no labels. So if you call > let my_a = ... in > let my_b = ... in > f my_b my_a > it doesn't matter whether you declared > let f (a:int) (b:int) = a * (b + 1);; > or > let f ~(a:int) ~(b:int) = a * (b + 1);; > and none will save you from the bug of passing the arguments in the > wrong order. A bug like this cost me a few nights of sleep a while ago. > > Is there a programming convention that would "enforce" labeling the > arguments in a total application of a certain function? There is a warning, but it is turned off by default. You just have to turn it on. $ ocaml -w L # let f ~(a:int) ~(b:int) = a * (b + 1);; val f : a:int -> b:int -> int = # f 2 3;; ^ Warning: labels were omitted in the application of this function. - : int = 8 --------------------------------------------------------------------------- Jacques Garrigue Kyoto University garrigue at kurims.kyoto-u.ac.jp JG ------------------- 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