From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 4492FBB81 for ; Mon, 13 Dec 2004 11:06:00 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id iBDA5xXD013395 for ; Mon, 13 Dec 2004 11:05:59 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA24446 for ; Mon, 13 Dec 2004 11:05:59 +0100 (MET) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.200]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id iBDA5wxk013392 for ; Mon, 13 Dec 2004 11:05:59 +0100 Received: by rproxy.gmail.com with SMTP id r35so1094456rna for ; Mon, 13 Dec 2004 02:05:58 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=tna/MAdSIMPXxeuW4JRVIdcvyac+kxazFPA00vhqpsqnDnyR1ty+wvz1nYtRgmYSOyGmL1t2EfQXuGA3SYm04/FWQkknywN7BYOIKDrBIP7Z3l16CyjLb0Z2WFCNthxQ2dmKHDR3dkAYUbIDJ2VEFcYWU+QfpBZXIb3dmp09s5Y= Received: by 10.38.76.13 with SMTP id y13mr2366765rna; Mon, 13 Dec 2004 02:05:57 -0800 (PST) Received: by 10.38.86.10 with HTTP; Mon, 13 Dec 2004 02:05:57 -0800 (PST) Message-ID: <877e9a17041213020570590649@mail.gmail.com> Date: Mon, 13 Dec 2004 05:05:57 -0500 From: Michael Walter Reply-To: Michael Walter To: Jacques Garrigue Subject: Re: [Caml-list] environment idiom Cc: Thomas.Fischbacher@physik.uni-muenchen.de, caml-list@inria.fr In-Reply-To: <20041213.182117.79057361.garrigue@math.nagoya-u.ac.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <877e9a170412121844b633bb8@mail.gmail.com> <877e9a1704121218456af9df9@mail.gmail.com> <20041213.182117.79057361.garrigue@math.nagoya-u.ac.jp> X-Miltered: at nez-perce with ID 41BD6987.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 41BD6986.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 syntax:01 computations:01 computations:01 runtime:01 avoiding:01 cheers:01 idiom:01 syntactic:01 functions:01 computation:01 jacques:01 int:01 garrigue:03 dec:03 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_BY_IP autolearn=disabled version=3.0.0 X-Spam-Level: On Mon, 13 Dec 2004 18:21:17 +0900 (JST), Jacques Garrigue > You make me curious. > By the way, if you want an example of non referentially code, > this looks easy: > > do > x <- readInt > y <- readInt > return (x-y) > > (The syntax and functions may be wrong but you get the idea.) > Of course according to your definition this contains nothing that is > not referentially transparent once you've taken the syntactic sugar. > > But looking at the code, it looks like readInt is executed twice > returning different results, i.e. this function does not always return > 0. Ah no, the key point is that this is not a function but a computation. In order to be not referentially transparent, you would have to run it. But you cannot do that -- the key point about the IO monad is that you can just compose computations involving I/O, but the only time those computations are actually executed is when "main" is invoked by the runtime. > So I suppose this is just an instance of what you see is _not_ what > you get, but wasn't referencial transparency about avoiding that? No, besides referential transparency having a definite technical meaning, you can clearly see what you are getting by simply looking at the type (IO Int). Cheers, Michael