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?