From: John Whitington <john@coherentgraphics.co.uk>
To: Philippe Veber <philippe.veber@gmail.com>
Cc: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] ignore semantics
Date: Mon, 17 Dec 2012 13:32:40 +0000 [thread overview]
Message-ID: <50CF1EF8.6010503@coherentgraphics.co.uk> (raw)
In-Reply-To: <CAOOOohRkuj75HebyUpSVVfL8i3xmff0BfkxAiCqLadNy0cWDng@mail.gmail.com>
Hi,
Philippe Veber wrote:
> This is a rather minor issue, but I was surprised by the following
> answers of the interpreter:
>
> OCaml version 4.00.1
>
> # ignore succ;;
> Warning 5: this function application is partial,
> maybe some arguments are missing.
> - : unit = ()
> # (fun _ -> ()) succ;;
> - : unit = ()
>
> I naively used to think the two expressions were equivalent. Reading
> pervasives.mli, I found that ignore is a primitive:
>
> external ignore : 'a -> unit = "%ignore"
>
> which means it is treated as a special case. Just for curiosity, what is
> the rationale for the warning in the first case?
Imagine you wrote:
ignore (output_something_and_return_something)
When what you wanted was
ignore (ouput_something_and_return_something ())
You'd want the partial application error there, even though you are
(intentionally) ignoring the return value of the function.
Cheers,
--
John Whitington
Director, Coherent Graphics Ltd
http://www.coherentpdf.com/
next prev parent reply other threads:[~2012-12-17 13:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-17 12:11 Philippe Veber
2012-12-17 13:32 ` John Whitington [this message]
2012-12-18 13:41 ` Philippe Veber
2012-12-18 1:28 ` Francois Berenger
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=50CF1EF8.6010503@coherentgraphics.co.uk \
--to=john@coherentgraphics.co.uk \
--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