[plt-scheme] libusb FFI binding
Noel Welsh wrote:
> ----- 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))
It's copy and paste from foreign.ss _enum definition. I'd liked the
syntax but a couldn't live with the constraints _enum puts on the caller
(I had to be able to pass arbitrary numbers and not only defined constats).
Probably you're right that either it should look like you wrote it or it
should have been abstracted as a macro like _enum.
--
regards,
Jakub Piotr Cłapa