caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Yaron Minsky <yminsky@janestreet.com>
To: John Whitington <john@coherentgraphics.co.uk>
Cc: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] Should -strict-sequence become the default?
Date: Sun, 27 Oct 2013 14:47:07 -0400	[thread overview]
Message-ID: <CACLX4jQrQugpBcJjy9-LZW=kF3XkkU69Tr-5AwVa0cOv4oCtWw@mail.gmail.com> (raw)
In-Reply-To: <526D5AF9.9030303@coherentgraphics.co.uk>

There are cases that the warning doesn't catch but should.  Here's an
example of a case that you'd like to catch.

# let z f = f (); 3;;
val z : (unit -> 'a) -> int = <fun>

With strict-sequence, this will instead compile to:

# let z f = f (); 3;;
val z : (unit -> unit) -> int = <fun>

I think the strict-sequence behavior is strictly preferable.

y

On Sun, Oct 27, 2013 at 2:27 PM, John Whitington
<john@coherentgraphics.co.uk> wrote:
> Hi,
>
>
> Yaron Minsky wrote:
>>
>> Back in 3.12.1, a flag, -strict-sequence, was added that require that
>> the left-hand side of a sequence returns unit.  I suspect there's
>> broad agreement that -strict-sequence is the better default, but that
>> the old behavior has been left in place by default for compatibility
>> reasons.  I wonder if in the next major release, it would make sense
>> to make -strict-sequence the default, and have a flag for enabling the
>> old behavior.
>>
>> To say the obvious, such a change would be of no value to experienced
>> people and organizations that know how to set up the compiler to their
>> liking, but can be of real value to newcomers to the language.
>
>
> Isn't this covered (as a warning not an error) by warnings 5 & 10, both of
> which are default?
>
> Although the manual does say, rather ominously...
>
> "Note that warnings 5 and 10 are not always triggered, depending on the
> internals of the type checker."
>
> Does that caveat also apply to -strict-sequence? If not, why not, and could
> its implementation be back-ported to fix up warnings 5 and/or 10?
>
> feast:~ john$ ocaml -strict-sequence
>         OCaml version 4.01.0
>
> # let f x = x + 1;;
> val f : int -> int = <fun>
> # f 1; 0;;
> Error: This expression has type int but an expression was expected of type
> unit
>
> feast:~ john$ ocaml
>         OCaml version 4.01.0
>
> # let f x = x + 1;;
> val f : int -> int = <fun>
> # f 1; 0;;
> Warning 10: this expression should have type unit.
> - : int = 0
>
> The warning text for warning 10 could be changed to:
>
> "Warning 10: this expression should have type unit. If this is intended,
> consider using the 'ignore' function."
>
> Cheers,
>
> --
> John Whitington
> Director, Coherent Graphics Ltd
> http://www.coherentpdf.com/
>

  reply	other threads:[~2013-10-27 18:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-27 14:20 Yaron Minsky
2013-10-27 14:43 ` Lukasz Stafiniak
2013-10-27 18:27 ` John Whitington
2013-10-27 18:47   ` Yaron Minsky [this message]
2013-10-28 12:42     ` ygrek
2013-10-28 13:00       ` Yaron Minsky
2013-10-28 13:08         ` Jacques Garrigue
2013-10-28 13:18           ` Mark Shinwell
2013-10-28 14:13             ` Malcolm Matalka

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='CACLX4jQrQugpBcJjy9-LZW=kF3XkkU69Tr-5AwVa0cOv4oCtWw@mail.gmail.com' \
    --to=yminsky@janestreet.com \
    --cc=caml-list@inria.fr \
    --cc=john@coherentgraphics.co.uk \
    /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;
as well as URLs for NNTP newsgroup(s).