chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] do I use define-foreign-variable correctly ?


From: Kon Lovett
Subject: Re: [Chicken-users] do I use define-foreign-variable correctly ?
Date: Wed, 7 Feb 2007 10:31:12 -0800

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Feb 7, 2007, at 6:41 AM, minh thu wrote:

#>!
#include <X.h>
#include <keysym.h>
<#

(define-foreign-variable c-escape-key int "XK_Escape")
(define escape-key c-escape-key)

Do I need to have those two lines too be able to use escape-key as a
Scheme symbol for the C #defined XK_Escape value ?

Umm, depends. Do you want it visible outside of the compilation unit (i.e. exportable)? then '(define escape-key (foreign-value "XK_Escape" int))' is enough. (I might make the symbol uppercase just to emphasize it is a constant.) Also 'define-foreign-variable' has overhead that you don't want for a constant, it isn't mutable so conversion should only be done once. ('foreign-value' is a wrapper around 'define-foreign-variable' that creates the variable, gets its' value, & throws away the variable, returning only the value.)


Thanks,
thu


_______________________________________________
Chicken-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/chicken-users

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)

iEYEARECAAYFAkXKGvAACgkQJJNoeGe+5O7VigCbBUu6oQYDViFjWI37JJZNgqgS
a80AnjSF4nsgleQlFLN+W5vfxic+RVgW
=du8v
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]