Why is tcl broken?
Andy Freeman
anamax at earthlink.net
Thu Jul 1 12:19:07 EDT 1999
More information about the Python-list mailing list
Thu Jul 1 12:19:07 EDT 1999
- Previous message (by thread): [Q] Static type checker for Python
- Next message (by thread): Why is tcl broken?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In article <377B454C.6F59 at mailserver.hursley.ibm.com>, Paul Duffin <pduffin at mailserver.hursley.ibm.com> wrote: > > Dynamic binding is another beast altogether, which Common Lisp and > > Scheme (statically scoped languages) allow in through a back door. > > If they are statically scoped how does the following work. All of the following book references are to Steele's Common Lisp the Language, 2nd edition. See Chapter 3 (esp pg 45, which explicitly states that the default scope is static), Chapter 1.2.3 (discussion of expansion), and Chapter 8 (esp 8.1). Chapter 3 has a nice description of what scope, extent, static, and dynamic mean. > Look at the following code. > > (let ((a 2)) > (let ((b 3)) > (+ a b))) > > When you expand the macro let you get something like. > > ((lambda (a) > ((lambda (b) > (+ a b)) 3)) 2) So far, so good. However, it doesn't really go further because lambda and application are primitives. > Which is equivalent (apart from side effects) of. > > (defun inner (b) > (+ a b)) > > (defun outer (a) > (inner 3)) > > (outer 2) No, it isn't. That's not what lambda means, and it isn't how macros work, and so on. Lambda "makes" an UNNAMED function IN a given lexical context - the above is an invalid transformation. One can use lambda to create CL variables with dynamic scope (that is indefinite scope and dynamic extent), but nested lambdas don't work as above. It isn't clear that nested lambdas EVER worked that way, even in dynamically scoped lisps. > So what is the process which associates the use of "a" inside inner > with the formal argument of outer. mu. Since there is no "inner" or "outer", the question makes no sense. > Lisp macros manipulate S-expressions but the macro definitions themselves > are interpreted differently to Lisp expressions. Macro definitions just define source to source transformations that happen "before" before evaluation. > A simple macro version of setq would convert from > (setq symbol '(list)) > to > (set 'symbol '(list)) Setq can not be defined in terms of set because set can't work for statically scoped vars, which is the default in CL. > Lisp does not really need macros, they are really just a way of > creating short cuts. I don't need * or even + either (if I have +1 and -1), but ..... (In fact, I can even get by with an "if" which always evaluates all of its arguments.) > I would say that Tcl (without macro system) can do anything that Lisp > (with macro system) can do. Since both are Turing machines.... -andy Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't.
- Previous message (by thread): [Q] Static type checker for Python
- Next message (by thread): Why is tcl broken?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list