feature of attribute building: automatic joining of (cdr attribute-list)

Terrence Brannon <[email protected]> Mon, 12 Jul 2004 17:46:17 -0400
Newsgroups gmane.lisp.scheme.ssax-sxml
Message-ID <[email protected]>
I was looking through some source code and came across this:

  (cvs-ref
      *macro*
      . ,(lambda (tag path)
           `(a (@ (href
                "http://cvs.sourceforge.net/viewcvs.py/kanren/kanren/"
                ,path))
          (code ,path))))

1/ I learned something. It appears that an attribute is built from a
list. The first element is the attribute name. The attribute value is
formed by joining together the remaining attributes. That's why the list
starting with href about can have three elements. I was used to only
having two elements in the list: one as the name and one as the value.
Example of newly discovered functionality:

  > (define path1 "/src/beta/")
  > (define path2 "2004/12/")
  > (define file "distro.tar.gz")
  > (define anchor `(a (@ (href "http://www.x.com" ,path1 ,path2 ,file))))
  > anchor
(a (@ (href "http://www.x.com" "/src/beta/" "2004/12/" "distro.tar.gz")))
  > (SXML->HTML anchor)

<a href="http://www.x.com/src/beta/2004/12/distro.tar.gz">#t
  >

2/ I notice that the *macro* qualifier was used when rewriting a cvs-ref
tag. Correct me if I'm wrong, but I believe the reason this is done is
so that the code tag can be properly expanded.

-- 
   (let recur ((lis x) (k k))
     (if (zero? k) (values '() lis)
	(receive (prefix suffix) (recur (cdr lis) (- k 1))
	  (values (cons (car lis) prefix) suffix)))))




-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com