From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 9418C7F8E8 for ; Thu, 22 May 2014 11:01:08 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of bmillwood@janestreet.com) identity=pra; client-ip=38.105.200.112; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="bmillwood@janestreet.com"; x-sender="bmillwood@janestreet.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of bmillwood@janestreet.com designates 38.105.200.112 as permitted sender) identity=mailfrom; client-ip=38.105.200.112; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="bmillwood@janestreet.com"; x-sender="bmillwood@janestreet.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mxout1.mail.janestreet.com) identity=helo; client-ip=38.105.200.112; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="bmillwood@janestreet.com"; x-sender="postmaster@mxout1.mail.janestreet.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuwBAKu7fVMmachwnGdsb2JhbABZg1tYgmmpOoEHAY15iH0BgQUIFg4BAQEBAQYWCTyCJQEBBAEjHQEBLAsBBAsJAgsNDRoDAgIhARIBBQEKAREGExKIGwMJCAMCCJRmkA+LGneEfwEFmgADCoYsEQaMOYEoaQQHgnWBS4RiBZMYgXWBPYlZgh2EARgpgnKBd2wB X-IPAS-Result: AuwBAKu7fVMmachwnGdsb2JhbABZg1tYgmmpOoEHAY15iH0BgQUIFg4BAQEBAQYWCTyCJQEBBAEjHQEBLAsBBAsJAgsNDRoDAgIhARIBBQEKAREGExKIGwMJCAMCCJRmkA+LGneEfwEFmgADCoYsEQaMOYEoaQQHgnWBS4RiBZMYgXWBPYlZgh2EARgpgnKBd2wB X-IronPort-AV: E=Sophos;i="4.98,885,1392159600"; d="scan'208";a="75246083" Received: from mxout1.mail.janestreet.com ([38.105.200.112]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 22 May 2014 11:01:06 +0200 Received: from tot-smtp.delacy.com ([172.27.22.15] helo=tot-smtp) by mxout1.mail.janestreet.com with esmtps (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.82) (envelope-from ) id 1WnOs5-0007NT-Cg for caml-list@inria.fr; Thu, 22 May 2014 05:01:05 -0400 Received: from tot-dmz-mxgoog1.delacy.com ([172.27.224.14] helo=mxgoog2.janestreet.com) by tot-smtp with esmtps (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1WnOs2-0008P9-8Z for caml-list@inria.fr; Thu, 22 May 2014 05:01:02 -0400 Received: from mail-qc0-f169.google.com ([209.85.216.169]) by mxgoog2.janestreet.com with esmtp (Exim 4.76) (envelope-from ) id 1WnOs2-00023Z-5j for caml-list@inria.fr; Thu, 22 May 2014 05:01:02 -0400 Received: by mail-qc0-f169.google.com with SMTP id e16so5246512qcx.0 for ; Thu, 22 May 2014 02:01:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=0LghTwQ3tv1lbxIM3y0y1KWKwiPUfdwadhowM1dJAkE=; b=PJ9zB9Z2AQ8CZAZecvKXU0hubaCVS3DdQzQn1FsOvf6+s4h2KR6aeY3oi6hMRLM2sK TVxndGwilXmNJ+ePapq+RGAjpReiRxcnuOWctASRaCY1J/UNC2SJ+CxlUMhcDEHEb5dU ApNmaVoTVBP1/xYrfLpmkMmwAFuK3yx+DmzwM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=0LghTwQ3tv1lbxIM3y0y1KWKwiPUfdwadhowM1dJAkE=; b=iFo/KCWKhBe1tYCXW3zl+Ugv9dBWTGXLmvf6hZDPaLDGsVeSQ8sdwrmKngmFnnaeTt qv2Cj+pWY6O0aPBU5lrjDS3Xlr/Km54kzTSoCCEUs0lMHl7bHnI7ewRWTDofep0v4cY+ vWL8bLQdHipc401kJZTtwMmZwT4B10VPZRdgMso5kAflb/UJ76Yc8k5euKXMA93+IZ4K SGtSf2WSu0eut3T+Mhye0dgAvxAKC4ML/wX03QpKNatA90k+8NV5VkARHsrkz+bkCHHr AkOiju1dZd/UVf1+C7zzr2yNlKlo0RZqZpsAarBFZ9nehsMeAsSeFjxXkBGnsmKXCoyn 2Oiw== X-Gm-Message-State: ALoCoQn/46KUK/YUqd3piCzSVZHmPs+QvuOgAZFRRSxbhWsgl8P7thbQEAoVSd/5O4rFwgGbqrt1rnSaU5VVLEgN2sM3e9E5wOSzgLgScOZCoz5eoJkfKCqC5jeWHirgT9iSUPL88LDc X-Received: by 10.140.80.67 with SMTP id b61mr11211043qgd.98.1400749262015; Thu, 22 May 2014 02:01:02 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.140.80.67 with SMTP id b61mr11211029qgd.98.1400749261906; Thu, 22 May 2014 02:01:01 -0700 (PDT) Received: by 10.140.103.74 with HTTP; Thu, 22 May 2014 02:01:01 -0700 (PDT) In-Reply-To: <537CD70F.9010503@ens-lyon.org> References: <762DAB52-9D2E-4002-80B0-526258DD7856@my.bristol.ac.uk> <2ABC1954-90FF-41CF-AB18-0C228A51CB8E@my.bristol.ac.uk> <537CD70F.9010503@ens-lyon.org> Date: Thu, 22 May 2014 10:01:01 +0100 Message-ID: From: Ben Millwood To: Martin Jambon Cc: David House , caml users , Ollie Frolovs Content-Type: multipart/alternative; boundary=001a11c136922d15ac04f9f95a83 Subject: Re: [Caml-list] Random.self_init in Jane Street Core --001a11c136922d15ac04f9f95a83 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 ty= pe > annotation: > > $ ocaml > OCaml version 4.01.0 > > # ignore print_endline;; > Warning 5: this function application is partial, > maybe some arguments are missing. > - : unit =3D () > 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 =E2=80=9Calias=E2=80=9D to Random.self_init was = assigned to >> nothing, so to speak, instead of calling the function. >> >> Many thanks, Dmitry! I=E2=80=99ve amended that line to let () =3D >> Random.self_init () and it works. >> >> On 21 May 2014, at 13:18, Dmitry Grebeniuk > > wrote: >> >> > Hello. >> > >> >> let _ =3D Random.self_init >> > >> > That's why I almost never use "let _ =3D ...", or >> > constrain "_" to some type when I use it. >> > Try to replace it with "let () =3D ..." and follow compiler >> > errors. Or with "let (_ : unit) =3D ...". >> >> >> -- >> 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 > --001a11c136922d15ac04f9f95a83 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On 2= 1 May 2014 17:40, Martin Jambon <martin.jambon@ens-lyon.org&g= t; 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:

=C2=A0 ignore (my_function foo);

Then this will start silently not calling [my_function] whenever
someone adds a second argument. You should instead use:

=C2=A0 ignore (my_function foo : Foo.t);

I think it used to be a problem but it no longer is. Recent versions of OCa= ml give a warning when passing a function, so there's no need for a typ= e annotation:

$ ocaml
=C2=A0 =C2=A0 =C2=A0 =C2=A0OCaml version 4.01.0

# ignore print_endline;;
Warning 5: this function application is partial,
maybe some arguments are missing.
- : unit =3D ()

You're right that t= his warning exists and mitigates the problem somewhat, but it doesn't s= ave you from the scenario where, say, a function changes from returning uni= t and throwing exceptions in the case of error to returning some error valu= e, 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 abo= ut.


On 21 May 2014 13:25, Ollie Frolovs
<ollie.frolovs.2012@my.bristol.ac.uk
<mailto:ollie.frolovs.2012@my.bristol.ac.uk>> wrote:

=C2=A0 =C2=A0 oh dear! i think i know what happened. self_init has never be= en
=C2=A0 =C2=A0 called in the first place! it requires a unit argument which = i did
=C2=A0 =C2=A0 not give it, so the =E2=80=9Calias=E2=80=9D to Random.self_in= it was assigned to
=C2=A0 =C2=A0 nothing, so to speak, instead of calling the function.

=C2=A0 =C2=A0 Many thanks, Dmitry! I=E2=80=99ve amended that line to let ()= =3D
=C2=A0 =C2=A0 Random.self_init () and it works.

=C2=A0 =C2=A0 On 21 May 2014, at 13:18, Dmitry Grebeniuk <gdsfh1@gmail.com
=C2=A0 =C2=A0 <mailto:gdsfh1@gmail.com>> wrote:

=C2=A0 =C2=A0 > Hello.
=C2=A0 =C2=A0 >
=C2=A0 =C2=A0 >> let _ =3D Random.self_init
=C2=A0 =C2=A0 >
=C2=A0 =C2=A0 > =C2=A0That's why I almost never use "let _ =3D = ...", or
=C2=A0 =C2=A0 > constrain "_" to some type when I use it.
=C2=A0 =C2=A0 > =C2=A0Try to replace it with "let () =3D ..." = and follow compiler
=C2=A0 =C2=A0 > errors. =C2=A0Or with "let (_ : unit) =3D ..."= .


=C2=A0 =C2=A0 --
=C2=A0 =C2=A0 Caml-list mailing list. =C2=A0Subscription management and arc= hives:
=C2=A0 =C2=A0 https://sympa.inria.fr/sympa/arc/caml-list
=C2=A0 =C2=A0 Beginner's list: http://groups.yahoo.com/group/oc= aml_beginners
=C2=A0 =C2=A0 Bug reports: http://caml.inria.fr/bin/caml-bugs



--001a11c136922d15ac04f9f95a83--