[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re : [Chicken-users] do I use define-foreign-variable correctly ?
From: |
minh thu |
Subject: |
Re : [Chicken-users] do I use define-foreign-variable correctly ? |
Date: |
Wed, 7 Feb 2007 19:36:54 +0100 |
2007/2/7, Kon Lovett <address@hidden>:
-----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)?
The escape-key, yes; the c-escape-key, no.
then '(define escape-key (foreign-value
"XK_Escape" int))' is enough.
Thanks !
(I might make the symbol uppercase just
to emphasize it is a constant.)
Ok.
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.)
Do I understand correctly : define-foreign-variable has overhead in this
case since I don't need it to be mutable and foreign-value has not
that overhead ?
Thanks,
thu