From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.4 required=5.0 tests=AWL,NO_REAL_NAME,SPF_FAIL autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 3E931BC69 for ; Thu, 29 Mar 2007 05:47:22 +0200 (CEST) Received: from selenite.metnet.navy.mil (selenite.metnet.navy.mil [192.16.167.32]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l2T3lJ38032015 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Thu, 29 Mar 2007 05:47:21 +0200 Received: (qmail 29046 invoked by uid 107); 29 Mar 2007 03:47:11 -0000 Received: from unknown (HELO Adric.metnet.fnmoc.navy.mil) (10.100.105.102) by selenite.metnet.navy.mil with SMTP; 29 Mar 2007 03:47:11 -0000 Received: by Adric.metnet.fnmoc.navy.mil (Postfix, from userid 760) id 2AF4DAD35; Wed, 28 Mar 2007 20:45:46 -0700 (PDT) To: loup.vaillant@gmail.com, caml-list@inria.fr Subject: Re: How must we teach lexical scope? Reply-To: oleg@pobox.com Errors-To: oleg@okmij.org From: oleg@pobox.com Message-Id: <20070329034546.2AF4DAD35@Adric.metnet.fnmoc.navy.mil> Date: Wed, 28 Mar 2007 20:45:46 -0700 (PDT) X-Miltered: at discorde with ID 460B36C7.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; oleg:01 metaocaml:01 endline:01 'x':01 lexical:01 lexical:01 wrote:01 variables:02 binding:02 string:02 scope:03 scope:03 languages:03 optimization:03 optimization:03 Loup Vaillant wrote: > Personally, I think environments are about the implementation of > lexical scope, not its specifications. I agree. A language system that eagerly performs substitutions inherent in the beta-rule needs no environments. An environment, which is a list of pending substitutions, is merely an optimization. A quite good optimization though. This is discussed in an article http://okmij.org/ftp/Scheme/misc.html#closure-misconceptions Regarding free variables: some of the multi-staged languages, including MetaOCaml, can literally manipulate code with `free variables'. For example, let bar u = print_endline "here"; .<.~u + 1>. in . .~(bar ..)>.;; Evaluating this code prints the string "here" and returns a code value, which can be printed as . ((x_1 + 3) + 1)>. We note that the function bar received a piece of code .. containing a free variable 'x' and incorporated that piece of code in the larger code. All while the binding for "x", "fun x -> ..." will be evaluated only in the future.