From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 4BE5CBBAF for ; Mon, 4 Aug 2008 07:58:05 +0200 (CEST) X-IronPort-AV: E=Sophos;i="4.31,302,1215381600"; d="scan'208";a="13697745" Received: from vau06-2-82-238-190-210.fbx.proxad.net (HELO [192.168.0.3]) ([82.238.190.210]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 04 Aug 2008 07:58:04 +0200 Message-ID: <48969A6B.5010005@sophia.inria.fr> Date: Mon, 04 Aug 2008 07:58:03 +0200 From: Yves Bertot User-Agent: Thunderbird 1.5.0.10 (Macintosh/20070221) MIME-Version: 1.0 To: Damien Guichard Cc: "caml-list@yquem.inria.fr" Subject: Re: [Caml-list] Error: This function is applied to too many arguments,maybe you forgot a `; ' References: <20080804005824.5FA4480000A0@mwinf2804.orange.fr> In-Reply-To: <20080804005824.5FA4480000A0@mwinf2804.orange.fr> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; ocaml:01 ocaml:01 extensively:01 caml-list:01 functions:01 functions:01 parentheses:01 parentheses:01 bertot:01 bertot:01 pair:01 int:01 argument:02 argument:02 functional:02 To be more precise, Ocaml being a functional language, any function, when applied to one argument, may return a new function which can in turn be applied to another argument. Thus if you write : (a (b)) (c), Ocaml (and most other functional programming languages), understand that a(b) is supposed to be a function, that returns another function, then applied to c. In practice, this trick is used extensively throughout functional programs, so that placing parentheses around arguments would result in a humongous number of parentheses. For this reason, a new convention for parentheses was enforced: you don't put any parentheses around function arguments, unless it is necessary for disambiguation (for instance, if you want b to be applied to c, and you don't place parentheses around the function part, so that (a(b))(c) is simply written a b c This means : a applied to b, and then to c, Now, if you want "a applied to the result of applying b to c", you write a (b c) Please note there are no parentheses around c. In practice, most functions taking several arguments are described in this manner, instead of being described as function taking a pair as argument. This is known as "currification" because Curry was one of the early mathematicians to advocate the idea that mathematics (and programming) could be described with only one-argument functions. In your case, both print_int and fac are one argument functions, as can be seen from their type. Yves