[plt-scheme] libusb FFI binding

From: Noel Welsh (noelwelsh at yahoo.com)
Date: Mon Mar 5 05:57:10 EST 2007

----- Original Message ----
From: Jakub Piotr Cłapa <jpc at pld-linux.org>

> I would be thankful if anybody could look into it (it's my first 
> nontrivial Scheme app) and comment on anything (style, good habits, errors).

I find this opaque:


  (define standard-usb-requests
    (let loop ([symbols '(get-status
                          clear-feature
                          set-feature = #x03
                          set-address = #x05
                          get-descriptor
                          set-descriptor
                          get-configuration
                          set-configuration
                          get-interface
                          set-interface
                          synch-frame)]
               [index 0])
      (unless (null? symbols)
        (when (and (pair? (cdr symbols))
                   (eq? '= (cadr symbols))
                   (pair? (cddr symbols)))
          (set! index (caddr symbols))
          (set-cdr! symbols (cdddr symbols)))
        (set-car! symbols (cons (car symbols) index))
        (loop (cdr symbols) (add1 index)))
      symbols))

What about:

  (define standard-usb-requests
              (map cons '(get-status
                          clear-feature
                          set-feature 
                          set-address 
                          get-descriptor
                          set-descriptor
                          get-configuration
                          set-configuration
                          get-interface
                          set-interface
                          synch-frame)
                         '(0 1 3 5 6 7 8 9 10 11 12)))

or better:

  (define standard-usb-requests
    '((get-status . 0) (clear-feature . 1) (set-feature . 3) (set-address . 5) (get-descriptor . 6) (set-descriptor . 7) (get-configuration . 8) (set-configuration . 9) (get-interface . 10) (set-interface . 11) (synch-frame . 12)))


N.






 
____________________________________________________________________________________
Need Mail bonding?
Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
http://answers.yahoo.com/dir/?link=list&sid=396546091


Posted on the users mailing list.