Group: fa.caml




Subject: [Caml-list] Re: How must we teach lexical scope?
From: oleg@pobox.com
Date: 3/29/2007 3:48:27 AM
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 .<fun x -> .~(bar .<x+3>.)>.;; Evaluating this code prints the string "here" and returns a code value, which can be printed as .<fun x_1 -> ((x_1 + 3) + 1)>. We note that the function bar received a piece of code .<x+3>. 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. _______________________________________________ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs