Subject: Re: progv question From: Erik Naggum <email@example.com> Date: 1997/10/19 Newsgroups: comp.lang.lisp Message-ID: <firstname.lastname@example.org> (I'll have to go look up the stuff in Norvig: PAIP before I answer the application-level part, but the language part is easy.) * Steve Gonedes | (let ((this '(a b c))) | (progv '(a b c) '(+ 1 2) | (eval this))) | | Is an error. I think I might know why, but some clarification would be | really great. simply put: because a symbol has both a function and a value slot, used in very distinct contexts. e.g., (a a) is a call to the function binding of `a' with the variable binding of `a' as the only argument. you can establish both with a form like this: (flet ((a (x) (* x x))) (let ((a 7)) (values #'a a (a a)))) | These all result in error: | | (progv '(a b c) '(list 1 2) | (eval (a b c))) you're trying to use `a' as a function, which it (probably) isn't. also, you would send the _result_ of this call to `eval'. if `a' actually was a function of two arguments, this would probably be even harder to debug. | (progv '(a b c) '(+ 1 2) | (eval '(a b c))) again, you're trying to use `a' as a function, but this is the correct use of `progv': the variable bindings for `b' and `c' are in effect dynamically. | (progv '(a b c) '(list 1 2) | (a b c)) again, calling `a' as a function, but at a very different time than above. | and of course the following work fine: | | (progv '(a b c) '(values 1 2) | (eval (list a b c))) you capture the variable binding of `a' in this case. | (progv '(a b c) '(values 1 2) | (funcall a b c)) and here you call `a' directly. | Just what is so special about LIST (or cons)? `eval' takes a list as argument. | Why aren't the symbols bound within the PROGV? oh, they are. you're just not referring the proper binding. also try (progv '(a b c) '(1 2 3) (eval '(list a b c))) | I am somewhat regretful for having to resort to actually asking someone | for help, as I usually come up with the solution - however long that may | take (usually very long). I have been trying various things for several | days and can't seem to give it a rest and just use apply or what have | you. sometimes, asking for help is the _only_ right thing. usually, however, it's more important to establish what you already know before you ask for help, or others will have a hard time actually helping you. in the process of establishing what I know and what I can't figure out, I have often found the answer myself, but it's somewhat easier for me to do this when I'm writing a request for help or (customer) support that I subsequently don't need to send. if I also felt that asking for help would be bad, I wouldn't even try this venue. | One more question (the nerve of this kid, huh?), why can't you apply the | special DEFUN, this isn't a macro is it (probably implementation | specific)? DEFUN is a macro. #\Erik -- if you think this year is "97", _you_ are not "year 2000 compliant". see http://www.naggum.no/emacs/ for Emacs-20-related material.