Adam Warner <usenet@consulting.net.nz> wrote:
+---------------
| Before I knew about &key I was using &rest to parse keyword parameters.
| I could parse a URI in these three forms:
| 1. (a :href "uri")
| 2. (a :href "uri" "description")
| 3. (a "description" :href "uri")
...
| This doesn't work...
| (defun a (&optional desc &key href) (write desc) (write href))
...
| I'd like to know how far I can go to provide such variation in input
| without having to resort to using &rest and then parsing the resulting
| list myself.
+---------------
If you can make one massive search & replace edit over your corpus
and replace all occurences of #2 & #3 with the following alternatives,
life might become a lot simpler for you:
2'. (a :href "uri" :text "description")
3'. (a :text "description" :href "uri")
-Rob
p.s. I replied only because I've been using Tim Bradshaw's HTOUT macro
a lot recently, and he similarly finesses the inverse problem -- what to
do about an HTML attribute that has no value. His solution: Force the Lisp
keyword to be provided an explicit value of NIL in that case, e.g.:
((:ul :compact nil) ; outputs <UL COMPACT>
:li "First item."
:li "Second item.")
p.p.s. In HTOUT, one writes #2 as:
((:a :href "uri") "description")
which is yet another solution that works.
-----
Rob Warnock, PP-ASEL-IA <rpw3@rpw3.org>
627 26th Avenue <URL:http://www.rpw3.org/>
San Mateo, CA 94403 (650)572-2607