On 21 May 2014 17:40, Martin Jambon 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. >> On 21 May 2014 13:25, Ollie Frolovs >> > > 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 > > 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 >> 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 >