From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p7Q9KYQm026796 for ; Fri, 26 Aug 2011 11:20:34 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0BAOJkV07RVdivkGdsb2JhbABCqBAIFAEBAQEJCQ0HFAQhgUABAQEBAgESAiwBGx0BAwELBgULOyEBAREBBQEcBhMih1AEnRgKjDuCVYUXO4htAgMGgyqDHASHXIs+iXeCaDyDag X-IronPort-AV: E=Sophos;i="4.68,284,1312149600"; d="scan'208";a="117254164" Received: from mail-qy0-f175.google.com ([209.85.216.175]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 26 Aug 2011 11:20:29 +0200 Received: by qyk4 with SMTP id 4so196755qyk.6 for ; Fri, 26 Aug 2011 02:20:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=KkQhc/53PoW0UgDLS/V4l592chmNsq0krzqeMq1HoD4=; b=WQbZsYgsO1Vok9uwwn8Z1HgNpEGh0nftflU5lz0KLMOKbjqp+N5cI9doP3P3N4GiTy YfCVkd6RIrmxz3RfI6vwv3BitCId+ImDi+HNOdIVEIJik00Z4LiEm4VGVT35WlxA0u+B tUHNfai5Jb/CywvY/QFizuX5R7P3YAXEx1YSw= MIME-Version: 1.0 Received: by 10.229.43.205 with SMTP id x13mr1129553qce.240.1314350426624; Fri, 26 Aug 2011 02:20:26 -0700 (PDT) Received: by 10.229.76.229 with HTTP; Fri, 26 Aug 2011 02:20:26 -0700 (PDT) In-Reply-To: References: Date: Fri, 26 Aug 2011 13:20:26 +0400 Message-ID: From: Dmitry Bely To: Philippe Veber Cc: Caml List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p7Q9KYQm026796 Subject: Re: [Caml-list] Labelled parameter bug? On Wed, Aug 24, 2011 at 7:01 PM, Philippe Veber wrote: >> The following fragment compiles without a warning but produces strange >> results: >> >> let f ?(p1="p1") ~p2 p3 = >>  Printf.printf "p1=%s, p2=%s, p3=%s\n" p1 p2 p3 >> >> let _ = >>  f "p2" "p3"; (* 1 *) >>  let f2 = f "p2" in >>  f2 "p3" (* 2 *) (...) > This first application also applies optional arguments situated before the > anoymous argument, so it remains the second (labeled) argument only. > > There is indeed a special case where you can drop labels if you provide the > exact number of arguments. This means that f "p2" "p3" is equivalent to f > ~p2:"p2" "p3". This is written in the manual > (http://caml.inria.fr/pub/docs/manual-ocaml/manual006.html) : > > "As an exception to the above parameter matching rules, if an application is > total, labels may be omitted. In practice, most applications are total, so > that labels can be omitted in applications. " > > So this is actually the intended behavior, AFAIU Indeed. Thanks for the detailed explanation. But shouldn't the compiler decide that the partial application skipping labeled parameter is suspicious and generate a warning? - Dmitry Bely