[gambit-list] Segfault while importing enum

Mikael mikael.rcv at gmail.com
Wed Nov 2 15:25:58 EDT 2011


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 at gmail.com>

> 2011/11/2 Marc Feeley <feeley at 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 at iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20111102/8421c278/attachment.htm>


More information about the Gambit-list mailing list