caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Should -strict-sequence become the default?
@ 2013-10-27 14:20 Yaron Minsky
  2013-10-27 14:43 ` Lukasz Stafiniak
  2013-10-27 18:27 ` John Whitington
  0 siblings, 2 replies; 9+ messages in thread
From: Yaron Minsky @ 2013-10-27 14:20 UTC (permalink / raw)
  To: caml-list

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.

y

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Should -strict-sequence become the default?
  2013-10-27 14:20 [Caml-list] Should -strict-sequence become the default? Yaron Minsky
@ 2013-10-27 14:43 ` Lukasz Stafiniak
  2013-10-27 18:27 ` John Whitington
  1 sibling, 0 replies; 9+ messages in thread
From: Lukasz Stafiniak @ 2013-10-27 14:43 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 113 bytes --]

I am very much in favor of restrictive defaults. I tend to not change
compiler settings if I am not forced to...

[-- Attachment #2: Type: text/html, Size: 244 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Should -strict-sequence become the default?
  2013-10-27 14:20 [Caml-list] Should -strict-sequence become the default? Yaron Minsky
  2013-10-27 14:43 ` Lukasz Stafiniak
@ 2013-10-27 18:27 ` John Whitington
  2013-10-27 18:47   ` Yaron Minsky
  1 sibling, 1 reply; 9+ messages in thread
From: John Whitington @ 2013-10-27 18:27 UTC (permalink / raw)
  To: Yaron Minsky; +Cc: caml-list

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/


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Should -strict-sequence become the default?
  2013-10-27 18:27 ` John Whitington
@ 2013-10-27 18:47   ` Yaron Minsky
  2013-10-28 12:42     ` ygrek
  0 siblings, 1 reply; 9+ messages in thread
From: Yaron Minsky @ 2013-10-27 18:47 UTC (permalink / raw)
  To: John Whitington; +Cc: caml-list

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/
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Should -strict-sequence become the default?
  2013-10-27 18:47   ` Yaron Minsky
@ 2013-10-28 12:42     ` ygrek
  2013-10-28 13:00       ` Yaron Minsky
  0 siblings, 1 reply; 9+ messages in thread
From: ygrek @ 2013-10-28 12:42 UTC (permalink / raw)
  To: caml-list

Hello,

I have one problem with this option. Basically - it disables warning 21. Consider:

$ ocaml

# let f () = exit 0; 1;;
Characters 11-17:
  let f () = exit 0; 1;;
             ^^^^^^
Warning 21: this statement never returns (or has an unsound type.)
val f : unit -> int = <fun>

$ ocaml -strict-sequence

# let f () = exit 0; 1;;
val f : unit -> int = <fun>

So I choose to disable this option and strictly require `let () =` when calling callbacks.

-- 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Should -strict-sequence become the default?
  2013-10-28 12:42     ` ygrek
@ 2013-10-28 13:00       ` Yaron Minsky
  2013-10-28 13:08         ` Jacques Garrigue
  0 siblings, 1 reply; 9+ messages in thread
From: Yaron Minsky @ 2013-10-28 13:00 UTC (permalink / raw)
  To: ygrek; +Cc: caml-list

Interesting.  Anyone know if the disabling of 21 with strict-sequence
is a fundamental issue, or just an accident?  It seems best to have
both available at once.

y

On Mon, Oct 28, 2013 at 8:42 AM, ygrek <ygrek@autistici.org> wrote:
> Hello,
>
> I have one problem with this option. Basically - it disables warning 21. Consider:
>
> $ ocaml
>
> # let f () = exit 0; 1;;
> Characters 11-17:
>   let f () = exit 0; 1;;
>              ^^^^^^
> Warning 21: this statement never returns (or has an unsound type.)
> val f : unit -> int = <fun>
>
> $ ocaml -strict-sequence
>
> # let f () = exit 0; 1;;
> val f : unit -> int = <fun>
>
> So I choose to disable this option and strictly require `let () =` when calling callbacks.
>
> --
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Should -strict-sequence become the default?
  2013-10-28 13:00       ` Yaron Minsky
@ 2013-10-28 13:08         ` Jacques Garrigue
  2013-10-28 13:18           ` Mark Shinwell
  0 siblings, 1 reply; 9+ messages in thread
From: Jacques Garrigue @ 2013-10-28 13:08 UTC (permalink / raw)
  To: Yaron Minsky; +Cc: ygrek, caml-list

[-- Attachment #1: Type: text/plain, Size: 1675 bytes --]

Yaron Minsky yminsky@janestreet.com:

> Interesting.  Anyone know if the disabling of 21 with strict-sequence
> is a fundamental issue, or just an accident?  It seems best to have
> both available at once.


This is most certainly an accident.
I should look into that.
(However preserving 21 would change some error messages too)

This said, I personally do not like the statement warning, and I'm not a
big fan of
-strict-sequence either, as both require changes in APIs.
This said, I prefer the option to the warning: at least it gives strong
guarantees.

Jacques

>
> On Mon, Oct 28, 2013 at 8:42 AM, ygrek <ygrek@autistici.org <javascript:;>>
> wrote:
> > Hello,
> >
> > I have one problem with this option. Basically - it disables warning 21.
> Consider:
> >
> > $ ocaml
> >
> > # let f () = exit 0; 1;;
> > Characters 11-17:
> >   let f () = exit 0; 1;;
> >              ^^^^^^
> > Warning 21: this statement never returns (or has an unsound type.)
> > val f : unit -> int = <fun>
> >
> > $ ocaml -strict-sequence
> >
> > # let f () = exit 0; 1;;
> > val f : unit -> int = <fun>
> >
> > So I choose to disable this option and strictly require `let () =` when
> calling callbacks.
> >
> > --
> >
> > --
> > Caml-list mailing list.  Subscription management and archives:
> > https://sympa.inria.fr/sympa/arc/caml-list
> > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> > Bug reports: http://caml.inria.fr/bin/caml-bugs
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>

[-- Attachment #2: Type: text/html, Size: 2798 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Should -strict-sequence become the default?
  2013-10-28 13:08         ` Jacques Garrigue
@ 2013-10-28 13:18           ` Mark Shinwell
  2013-10-28 14:13             ` Malcolm Matalka
  0 siblings, 1 reply; 9+ messages in thread
From: Mark Shinwell @ 2013-10-28 13:18 UTC (permalink / raw)
  To: Jacques Garrigue; +Cc: Yaron Minsky, ygrek, caml-list

On 28 October 2013 09:08, Jacques Garrigue <garrigue@math.nagoya-u.ac.jp> wrote:
> This said, I personally do not like the statement warning, and I'm not a big
> fan of
> -strict-sequence either, as both require changes in APIs.

I'm very much in favour of making -strict-sequence the default.

It doesn't seem to me that, given suitable notice disseminated through this
mailing list, the change is overly disruptive.  (The fixing of code
should largely
be a mechanical process; and the error can be quickly turned off in the event
of having a particularly problematic source file.)

Mark

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Should -strict-sequence become the default?
  2013-10-28 13:18           ` Mark Shinwell
@ 2013-10-28 14:13             ` Malcolm Matalka
  0 siblings, 0 replies; 9+ messages in thread
From: Malcolm Matalka @ 2013-10-28 14:13 UTC (permalink / raw)
  To: Mark Shinwell; +Cc: Jacques Garrigue, Yaron Minsky, ygrek, caml-list

Sounds like a job for the massive opam computing grid!

Mark Shinwell <mshinwell@janestreet.com> writes:

> On 28 October 2013 09:08, Jacques Garrigue <garrigue@math.nagoya-u.ac.jp> wrote:
>> This said, I personally do not like the statement warning, and I'm not a big
>> fan of
>> -strict-sequence either, as both require changes in APIs.
>
> I'm very much in favour of making -strict-sequence the default.
>
> It doesn't seem to me that, given suitable notice disseminated through this
> mailing list, the change is overly disruptive.  (The fixing of code
> should largely
> be a mechanical process; and the error can be quickly turned off in the event
> of having a particularly problematic source file.)
>
> Mark

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-10-28 14:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-27 14:20 [Caml-list] Should -strict-sequence become the default? Yaron Minsky
2013-10-27 14:43 ` Lukasz Stafiniak
2013-10-27 18:27 ` John Whitington
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

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).