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

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/


  parent reply	other threads:[~2013-10-27 18:27 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 [this message]
2013-10-27 18:47   ` Yaron Minsky
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=526D5AF9.9030303@coherentgraphics.co.uk \
    --to=john@coherentgraphics.co.uk \
    --cc=caml-list@inria.fr \
    --cc=yminsky@janestreet.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;
as well as URLs for NNTP newsgroup(s).