caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Martin Jambon <martin.jambon@ens-lyon.org>
To: Ben Millwood <bmillwood@janestreet.com>
Cc: David House <dhouse@janestreet.com>,
	caml users <caml-list@inria.fr>,
	 Ollie Frolovs <ollie.frolovs.2012@my.bristol.ac.uk>
Subject: Re: [Caml-list] Random.self_init in Jane Street Core
Date: Thu, 22 May 2014 10:22:34 -0700	[thread overview]
Message-ID: <537E325A.4030304@ens-lyon.org> (raw)
In-Reply-To: <CA+MHO52uUwtMTTdnCiSN62aaNkCf5yi=5KSTFBvMJXLm2Lf7VA@mail.gmail.com>

On Thu 22 May 2014 02:01:01 AM PDT, Ben Millwood wrote:
> On 21 May 2014 17:40, Martin Jambon <martin.jambon@ens-lyon.org
> <mailto:martin.jambon@ens-lyon.org>> wrote:
>
>     On Wed 21 May 2014 05:28:00 AM PDT, David House wrote:
>
>         Relatedly, one should be careful using the [ignore] function.
>         Always
>         give its argument a type signature. E.g. if you do this:
>
>           ignore (my_function foo);
>
>         Then this will start silently not calling [my_function] whenever
>         someone adds a second argument. You should instead use:
>
>           ignore (my_function foo : Foo.t);
>
>
>     I think it used to be a problem but it no longer is. Recent
>     versions of OCaml give a warning when passing a function, so
>     there's no need for a type annotation:
>
>     $ ocaml
>            OCaml version 4.01.0
>
>     # ignore print_endline;;
>     Warning 5: this function application is partial,
>     maybe some arguments are missing.
>     - : unit = ()
>
>
> You're right that this warning exists and mitigates the problem
> somewhat, but it doesn't save you from the scenario where, say, a
> function changes from returning unit and throwing exceptions in the
> case of error to returning some error value, or vice versa. It seems
> just generally if the return type of a function you use changes that's
> probably something you'd want noise made about.

I can see it's a problem when the function that throws an exception 
does not return unit. However if the original function returns unit, we 
don't use ignore in the first place and we get a warning if the return 
type changes. If the original function returns something but then 
switches to unit + exception, I guess the compiler could warn against 
that too:

  Warning X: this 'ignore' is useless


>         On 21 May 2014 13:25, Ollie Frolovs
>         <ollie.frolovs.2012@my.__bristol.ac.uk
>         <mailto:ollie.frolovs.2012@my.bristol.ac.uk>
>         <mailto:ollie.frolovs.2012@my.__bristol.ac.uk
>         <mailto:ollie.frolovs.2012@my.bristol.ac.uk>>> wrote:
>
>             oh dear! i think i know what happened. self_init has never
>         been
>             called in the first place! it requires a unit argument
>         which i did
>             not give it, so the “alias” to Random.self_init was
>         assigned to
>             nothing, so to speak, instead of calling the function.
>
>             Many thanks, Dmitry! I’ve amended that line to let () =
>             Random.self_init () and it works.
>
>             On 21 May 2014, at 13:18, Dmitry Grebeniuk
>         <gdsfh1@gmail.com <mailto:gdsfh1@gmail.com>
>             <mailto:gdsfh1@gmail.com <mailto:gdsfh1@gmail.com>>> wrote:
>
>             > Hello.
>             >
>             >> let _ = Random.self_init
>             >
>             >  That's why I almost never use "let _ = ...", or
>             > constrain "_" to some type when I use it.
>             >  Try to replace it with "let () = ..." and follow compiler
>             > errors.  Or with "let (_ : unit) = ...".
>
>
>             --
>             Caml-list mailing list.  Subscription management and archives:
>         https://sympa.inria.fr/sympa/__arc/caml-list
>         <https://sympa.inria.fr/sympa/arc/caml-list>
>             Beginner's list:
>         http://groups.yahoo.com/group/__ocaml_beginners
>         <http://groups.yahoo.com/group/ocaml_beginners>
>             Bug reports: http://caml.inria.fr/bin/caml-__bugs
>         <http://caml.inria.fr/bin/caml-bugs>
>
>
>
>
>
>     --
>     Caml-list mailing list.  Subscription management and archives:
>     https://sympa.inria.fr/sympa/__arc/caml-list
>     <https://sympa.inria.fr/sympa/arc/caml-list>
>     Beginner's list: http://groups.yahoo.com/group/__ocaml_beginners
>     <http://groups.yahoo.com/group/ocaml_beginners>
>     Bug reports: http://caml.inria.fr/bin/caml-__bugs
>     <http://caml.inria.fr/bin/caml-bugs>
>
>



  reply	other threads:[~2014-05-22 17:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-21 12:10 Ollie Frolovs
2014-05-21 12:18 ` Dmitry Grebeniuk
2014-05-21 12:25   ` Ollie Frolovs
2014-05-21 12:28     ` David House
2014-05-21 16:40       ` Martin Jambon
2014-05-22  9:01         ` Ben Millwood
2014-05-22 17:22           ` Martin Jambon [this message]
2014-05-23  0:12 ` Nathan Mishra Linger
2014-05-23  0:15   ` Nathan Mishra Linger

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=537E325A.4030304@ens-lyon.org \
    --to=martin.jambon@ens-lyon.org \
    --cc=bmillwood@janestreet.com \
    --cc=caml-list@inria.fr \
    --cc=dhouse@janestreet.com \
    --cc=ollie.frolovs.2012@my.bristol.ac.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).