Path: utzoo!attcan!uunet!yale!krulwich-bruce From: krulwich-bruce@CS.YALE.EDU (Bruce Krulwich) Newsgroups: comp.lang.scheme Subject: Re: Macros; lexcial scope Message-ID: <30160@yale-celray.yale.UUCP> Date: 26 May 88 14:53:24 GMT References: <8805251659.AA00682@tub.UUCP> Sender: root@yale.UUCP Reply-To: krulwich-bruce@CS.YALE.EDU (Bruce Krulwich) Organization: Yale University Computer Science Dept, New Haven CT 06520-2158 Lines: 29 In article <8805251659.AA00682@tub.UUCP> net@TUB.BITNET (Oliver Laumann) writes: >Consider the following example: > (define x 1) > (define-macro (m) x) > (let ((x 2)) > (m)) >Would you expect that (m) evaluates to 1 or to 2? In both Common Lisp >(using a different syntax, of course) and C-Scheme, (m) returns 1 in the >example above. Thus, it looks as if the first time the macro body is >evaluated, the evaluation takes place in the lexical scope of the >define-macro. Rather, that the macro is evaluated in the lexical scope in which it was defined, just like regular functions. >Now consider a slighly more complex example: > (define x 1) > (let ((x 2)) > (define-macro (m) x) > (let ((x 3)) > (m))) >In both Common Lisp and C-Scheme, this evaluates to 1. T's DEFINE-SYNTAX does what you want in both of these cases, evaluating to 1 in the first case and 2 in the second case. Bruce Krulwich