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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id A1EBE7F712 for ; Mon, 3 Feb 2014 10:20:41 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of arnaud.spiwack@gmail.com) identity=pra; client-ip=74.125.82.41; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="arnaud.spiwack@gmail.com"; x-sender="arnaud.spiwack@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of arnaud.spiwack@gmail.com designates 74.125.82.41 as permitted sender) identity=mailfrom; client-ip=74.125.82.41; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="arnaud.spiwack@gmail.com"; x-sender="arnaud.spiwack@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-wg0-f41.google.com) identity=helo; client-ip=74.125.82.41; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="arnaud.spiwack@gmail.com"; x-sender="postmaster@mail-wg0-f41.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AksCAMRe71JKfVIplGdsb2JhbABZhBuDAbwSCBYOAQEBAQcLCwkSKoIlAQEEASMdATgBAwELAQUFBAEGNwICIhIBBQEcBhuHaQMJCJ9kjAmDXJNcJw2JMxEBBQyRc4FJBJRCg2iQNBgpgWWCdTs X-IPAS-Result: AksCAMRe71JKfVIplGdsb2JhbABZhBuDAbwSCBYOAQEBAQcLCwkSKoIlAQEEASMdATgBAwELAQUFBAEGNwICIhIBBQEcBhuHaQMJCJ9kjAmDXJNcJw2JMxEBBQyRc4FJBJRCg2iQNBgpgWWCdTs X-IronPort-AV: E=Sophos;i="4.95,771,1384297200"; d="scan'208";a="47554660" Received: from mail-wg0-f41.google.com ([74.125.82.41]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 03 Feb 2014 10:20:41 +0100 Received: by mail-wg0-f41.google.com with SMTP id n12so3264038wgh.2 for ; Mon, 03 Feb 2014 01:20:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=XCW0R+KcwlHveg3P1ip7V8Q2/7y+ip/yEgUKuwYzPZw=; b=itYUiZsOxoAMCbE4DSpiWO4d9+8LnU0i2DGDOjw+CfGzwAwZ65+NtaDx9/yXi0Jjjm nxhxpJ1hUMpl3m6qdjxJcTv1t+jWplwrntuuILOqaR9c/OLvxMMx4t8yMLL2vkUCQU5j FSvxfx6l9ELLijLwUoKCBxa9Ys8ijsXuivGRlpA5kmRGl2LC1RU00QqCM1gyXj5DuWK0 o/jYtemi9koNVpCNp6YaLrXLnJWTegVyVRvyzMeWMBgC/cmYKBSCubIdRPrTN1537b3h i9REqkEq8PNtB1htqYwnANvDOlFnnCkAXSZWgUv/eaZrvJv8cKE4wAfMcBWR5KD1aj8a +sEg== X-Received: by 10.180.24.227 with SMTP id x3mr7969977wif.41.1391419240481; Mon, 03 Feb 2014 01:20:40 -0800 (PST) MIME-Version: 1.0 Sender: arnaud.spiwack@gmail.com Received: by 10.227.127.131 with HTTP; Mon, 3 Feb 2014 01:20:00 -0800 (PST) In-Reply-To: <20140201145230.GB1783@frosties> References: <20140121094939.GA13578@frosties> <20140123092009.GA20624@frosties> <20140127093204.GA24902@frosties> <20140201145230.GB1783@frosties> From: Arnaud Spiwack Date: Mon, 3 Feb 2014 10:20:00 +0100 X-Google-Sender-Auth: vbocBD5jsu-NqZdrLBW7Dx697T0 Message-ID: To: Goswin von Brederlow Cc: OCaML Mailing List Content-Type: multipart/alternative; boundary=f46d044283b0900a1e04f17d09a9 X-Validation-by: arnaud@spiwack.net Subject: Re: [Caml-list] Purity in ocaml --f46d044283b0900a1e04f17d09a9 Content-Type: text/plain; charset=UTF-8 Does it reorder? I would expect these two to be equivalent > > let x = f (g 1) (h ()) in > > and > > let f2 = f (g 1) in > let x = f (h ()) in > > and in the second case the order is clearly g before h. > It depends on the order of evaluation. I forgot to specify that I was taking right to left here (the order of evaluation is unspecified in Ocaml, if I remember correctly). > If the order is indeed to evaluate the last argument first then > > let t1 = h () in > let t2 = g 1 in > let x = f t2 t1 in > let y = t2 in > x + y > > It's not hard to preserve the order whatever it may be. > Yes, it is what I meant by "monadic form". To sum up, I'd say exceptions have some interesting properties, but are quite far from pure function as far as optimisation opportunities are concerned. --f46d044283b0900a1e04f17d09a9 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


Does it reorder? I would expect these tw= o to be equivalent

=C2=A0 =C2=A0 let x =3D f (g 1) (h ()) in

and

=C2=A0 =C2=A0 let f2 =3D f (g 1) in
=C2=A0 =C2=A0 let x =3D f (h ()) in

and in the second case the order is clearly g before h.

It depends on the order of evaluation. I forgot to specify that I was= taking right to left here (the order of evaluation is unspecified in Ocaml= , if I remember correctly).
=C2=A0
If the order is indeed to evaluate the last argument first then

=C2=A0 =C2=A0 let t1 =3D h () in
=C2=A0 =C2=A0 let t2 =3D g 1 in
=C2=A0 =C2=A0 let x =3D f t2 t1 in
=C2=A0 =C2=A0 let y =3D t2 in
=C2=A0 =C2=A0 x + y

It's not hard to preserve the order whatever it may be.

Yes, it is what I meant by "monadic form". To sum up, I= 'd say exceptions have some interesting properties, but are quite far f= rom pure function as far as optimisation opportunities are concerned.
--f46d044283b0900a1e04f17d09a9--