Path: utzoo!attcan!uunet!ncrlnk!ncrwic!wsuiar!mnjafar From: mnjafar@wsuiar.uucp Newsgroups: comp.lang.lisp Subject: about EVAL Message-ID: <200.266aae50@wsuiar.uucp> Date: 4 Jun 90 23:54:08 GMT Organization: Wichita State Univ., Wichita KS Lines: 85 I am a newcomer to lisp, so forgive my ignorance. I ran the test programs shown below on three different machines with Common Lisp. The results of the tests are shown below. Does anyone out there know the answer to why Eval behaves in the way it does. I looked in Guy Steele's book, but did not find an answer, maybe I don't know where to look . What exactly is supposed to happen when I issue an (eval '(setq i j)) inside a block ? The first test --------------------------------------------------- ;Test1.lsp ; (defun strange() (let (j i xpr) (setq i 12) (setq xpr '(setq j i)) (format t " ~% The value of i inside the function is : ~a~%" i) (format t " ~% The value of xpr inside the function is : ~a~%" xpr) (eval xpr) (format t " ~% The value of j inside the function is :~a~%" j) ) ) (strange) --------------------------------------------------- The second test --------------------------------------------------- ;Test2.lsp ; (defun strange() (let (j i xpr) (setq i 12) (setq xpr '(setq j i)) (format t " ~% The value of i inside the function is : ~a~%" i) (format t " ~% The value of xpr inside the function is : ~a~%" xpr) (eval xpr) (format t " ~% The value of j inside the function is :~a~%" j) j ) ) (setq i 13) (format t " ~% The value of i outside the function is : ~a~%" i) (strange) ---------------------------------------------------- The results obtained Machine: VAX 8650 running VMS 5.2 Vax Lisp V 2.2 Test | Error Message or value of j --------------------------------------------- test1 | symbol has no value : I test2 | nil Machine: SUN Sun Common Lisp, development environment 3.0.2 Test | Error Message or value of j --------------------------------------------- test1 | the symbol I has no global value test2 | nil Machine: PC/AT compatible Golden Common Lisp Version 1.01 Test | Error Message or value of j --------------------------------------------- test1 | 12 test2 | 12 Mohammad Jafar mnjafar@wsuiar.wsu.ukans.edu