This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Why does the GC frees my function?


        Hi,

I'm trying as a test to bind each one of the 26 alphacharacter to a
function. I read a file with the gh_load function containing

--
(bind-key #\a
	  (lambda ()
	    (display "a")))
--

then I bind the key with this function (alpha_biding is an array of 26
SCM)

--
SCM
bind_key (key, function)
     SCM key;
     SCM function;
{
  char c;

  if (!gh_char_p (key)) {
    return SCM_BOOL_F;
  }
  c = gh_scm2char (key);
  if (!isalpha (c)) {
    return SCM_BOOL_F;
  }
  if (isupper (c)) {
    c = tolower (c);
  }
  return alpha_binding[(int) c - (int) 'a'] = function;
}
--

Then I execute it but it seems that the GC frees the function. Why?
Can I tell the gcc not to do it (without binding my function to a
symbol)? Did i use a wrong way to do what i want to do?

As you see, I'm not very familiar (yet) with scheme and even less with
guile.

-- 
"Alors, je crois savoir ce qui n'allait pas. J'ai désactivé
 l'option : Send in rich HTML by default. Et je crois que c'était
 ça qui foutait le bordel."
-+- EF in Guide du linuxien pervers : "Bien configurer son Netscape"

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]