Path: utzoo!dciem!nrcaer!scs!spl1!laidbak!att!pacbell!lll-tis!helios.ee.lbl.gov!pasteur!ucbvax!decwrl!hplabs!otter!psa From: psa@otter.hple.hp.com (Patrick Arnold) Newsgroups: comp.lang.lisp Subject: Re: What's the value of lexical scoping? Message-ID: <1350015@otter.hple.hp.com> Date: 3 Jun 88 10:06:18 GMT Article-I.D.: otter.1350015 References: <24508@ucbvax.BERKELEY.EDU> Organization: Hewlett-Packard Laboratories, Bristol, UK. Lines: 40 I think there are two issues at stake here. Decent debuggers and binding rules. The first issue should be addressed by the language implementors. There is no reason why compiled code should not retain enough information to produce comparable debugging information. From what I remember of scheme it uses lexical scoping and has a very good debugger (though it sometimes has no information because of continuations but thats a different story). The biggest pain with dynamic binding is that it suffers from the downward (or upward) funarg problem. This refers to the potential for a procedure (function?) to capture variables from the environment in which it is being used. This may not always be desirable because it violates the "black box" notion of a procedure, namely that a procedure behaves the same in any context. Lexical binding does not have this problem. The justification for dynamic binding is that it makes some forms of abstraction easier to handle (this is important for programming in the large). Suppose we had two procedures which share a common sub-procedure. Further suppose we want to use implicit parameter passing (i.e are not passed explicitly) then in a statically scoped language you would be forced to repeat the definition of the shared procedure in order to be able to capture the implicit parameters whereas in a dynamically bound language you would be able to share a single definition amongst many procedures (carefully). So ideally a langauge should enable both styles of binding with there being a set of pragmatic guidelines about how they should and shouldn't be used in programming. The two types of binding enable two of the most important aspects of a structured approach to computer software, namely abstraction and information hiding. There is a basic (but expositional) discussion of this in Structure and Interpretation of Computer Programs by Abelson and Sussman on pages 321 to 323. Hope this helps. Patrick.