Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Dmitry Bely <dmitry.bely@gmail.com>
To: Philippe Veber <philippe.veber@gmail.com>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Labelled parameter bug?
Date: Fri, 26 Aug 2011 13:20:26 +0400	[thread overview]
Message-ID: <CAMT7qiTctYEihYnQLRzyyE0RM5aw-rR581fmzDxvZo99Vy+fVw@mail.gmail.com> (raw)
In-Reply-To: <CAOOOohT5VcOYis5e-JYv1PtjF1NYBwF1PRxyr4KAPkthCdh7DA@mail.gmail.com>

On Wed, Aug 24, 2011 at 7:01 PM, Philippe Veber
<philippe.veber@gmail.com> 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


  reply	other threads:[~2011-08-26  9:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-24 14:49 Dmitry Bely
2011-08-24 15:01 ` Philippe Veber
2011-08-26  9:20   ` Dmitry Bely [this message]
2011-08-26  9:58     ` Jacques Garrigue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMT7qiTctYEihYnQLRzyyE0RM5aw-rR581fmzDxvZo99Vy+fVw@mail.gmail.com \
    --to=dmitry.bely@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=philippe.veber@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox