Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 exptools; site whuts.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!lll-crg!dual!qantel!ihnp4!houxm!whuxl!whuts!choy From: choy@whuts.UUCP (CHOY) Newsgroups: net.lang.lisp Subject: Re: HELP: a bug in my lisp interpreter! Message-ID: <224@whuts.UUCP> Date: Mon, 12-Aug-85 09:53:06 EDT Article-I.D.: whuts.224 Posted: Mon Aug 12 09:53:06 1985 Date-Received: Sat, 17-Aug-85 06:12:02 EDT References: <16700002@uiucuxc> Organization: AT&T Bell Laboratories Lines: 45 > > HELP: A strange Bug! > > I got an exprimental lisp from a friend to play with. It has > a strange bug. > Here is a session which illustrates the bug. Notice how > the variable foo gets changed after the eval is called. > > ==> (defun test macro (args) `(cdr (quote ,(cadr args)))) > test > > ==> (test (a b c d)) > (b c d) > > ==> (setq foo '(test (a b c d))) > (test (a b c d)) > > ==> (eval foo) > (b c d) > > ==> foo > (cdr '(a b c d)) > > ; why did the foo change? I tried the same thing in real MAClisp and Franz > ; and the value of foo was retained and was not changed. > > ; Have you got any idea what went wrong? > > Thank you > Navin Chandra > (to reply: please post a response on the net.lang.lisp, mail never > really seems to reach me) This is not a bug. This is a feature to save you some computation. Remember "test" is a macro. When you evaluate the expression "(test (a b c d))", it will be expanded to "(cdr '(a b c d))" and your lisp interpreter replace the original expression to the expanded expression. Therefore, no expansion need to be done next time. In Franz Lisp, there is a flag to turn on and off the replacement from the original expression to the expanded expression. By the way, does anybody know how to make a single symbol as a macro token? I mean the original expression will be "symbol" instead of "(symbol)".