It's fine as long as the case listing has few elements (<30-50 somewhere). Your else clause probably wants an error call in it btw.

2011/11/2 Vok Vojwo <ceving@gmail.com>
2011/11/2 Marc Feeley <feeley@iro.umontreal.ca>:
>
> Alternatively, use this macro to import C enums and constants:
>

I am experimenting with a symbol version:

(define gtk-window-new
 (let ((toplevel ((c-lambda () int "___result = GTK_WINDOW_TOPLEVEL;")))
       (popup ((c-lambda () int "___result = GTK_WINDOW_POPUP;")))
       (new (c-lambda (int) GtkWidget* "gtk_window_new")))
   (lambda (type)
     (new (case type
            ((toplevel) toplevel)
            ((popup) popup)
            (else "gtk-window-new: invalid type: " type))))))

This seems to be more natural in Scheme and the top level environment
would be smaller. But the code would be slower because of the case
dispatching. And every mapped C function accepting enumerations would
have three closures: the let, the lambda and the c-lambda.

Is this inappropriate expensive?
_______________________________________________
Gambit-list mailing list
Gambit-list@iro.umontreal.ca
https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list