SXML-to-HTML-ext.scm issues

Terrence Brannon <[email protected]> Sun, 04 Jul 2004 16:17:40 -0400
Newsgroups gmane.lisp.scheme.ssax-sxml
Message-ID <[email protected]>
1/ this file has 2 functions of general utility: lookup-def and 
signif-tail. I think these belong in util.scm not here because they have 
general usefulness

2/ I was using lookup-def on a sparse association list, meaning even 
though I was checking about 8 things against it, the association list 
only had 1 or 2 associations on it. So I expected a lot of things not to 
be found and I did not want my screen littered with warnings. I added a 
default warn? option to lookup-def.

; Look up a value associated with a symbolic key in alist (key value)
; and return (value)
; If failed, write a warning and return the default value, if non-#f
; A lookup failure is fatal if the default value is #f
; if warn? is #f, then no message is sent to the error channel
(define (lookup-def key alist default-value . warn?)
  (let ((warn? (if (pair? warn?) (car warn?) #t)))
    (cond
     ((assq key alist) => cdr)
     (default-value
       (begin
         (if warn?
             (cerr "Failed to find a binding for a key " key
                   ". The default value " default-value " will be used"))
         default-value))
     (else
      (error "Failed to find a binding for a key " key)))))

3/ Is is possible to checkin util.scm and SXML-to-HTML-ext.scm with my 
suggested mods? I would like to stay synchronized with the standard 
repository for these functions.

4/ Will Kiril's PLT version also have my updates if they get checked in?

-- 
  (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