Subject: Re: help w/ &key in macros From: Erik Naggum <cl@naggum.no> Date: 1998/06/01 Newsgroups: comp.lang.lisp Message-ID: <3105686891933414@naggum.no> [ a slightly corrected version 2. ] * David Bakhash | I was able to get passed this by doing the following, MUCH simpler trick. | basically, I used &rest instead of &optional and it works, oddly enough: | | (defmacro f (x &rest y-list &key k1 k2 &aux (y (first y-list))) | (...)) | | and no destructuring-bind needed. I guess &rest and &optional read | parameters differently. Anyway, just wanted to let you know. It took me | a while to figure that out, and I only got there by trial-and-error. this shouldn't work. (f 1 2 :k1 3 :k2 4) should signal an error because the resulting rest list (2 :k1 3 :k2 4) is not a valid plist, i.e., it does not have an even number of elements, as per the definition of &REST with &KEY. (f 1 :k1 2 :k2 3) should bind Y to :K1. Allegro CL 4.3, 4.3.1, and 5.0 concur. I wonder how you determined that it works. you're _much_ better off reading and understanding the standard (or any language specification) than spending time on random stabs in any problem space -- you'll never know what you hit, nor whether you hit something by accident or by design. worse, more often than not what happens to "work" is a special case. please see the HyperSpec. if it's too hard to read, you need to back off and realize that you shouldn't try to solve the problem at hand until you understand what you're doing. you'll get all the help you need here in comp.lang.lisp if you want to understand the language (I know I have benefited thusly) instead of just randomly trying something and then get yourself in need of help when you're confused. more often than not, some minor expectation can block understanding and lead you down weird paths (it has happened to me several times), and the further you go down that path, especially with code you don't understand why doesn't work, the harder it is to recover where you came from and give you the guidance you need to choose the right path. #:Erik -- "Where do you want to go to jail today?" -- U.S. Department of Justice Windows 98 slogan