guile-devel
[Top][All Lists]
Advanced

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

Re: scm_* API extension? [was] scm_* API question


From: Rob Browning
Subject: Re: scm_* API extension? [was] scm_* API question
Date: Wed, 31 Jul 2002 17:14:56 -0500
User-agent: Gnus/5.090006 (Oort Gnus v0.06) Emacs/21.2 (i386-pc-linux-gnu)

Christopher Cramer <address@hidden> writes:

> I have no idea why you think it would better, but with certain types
> of applications, it's impossible.

There are also cases where it seems clearer if the C side deals with
modules explicitly.  For example, we had a decent amount of trouble in
gnucash because we were using gh_eval_str on the C side to get scheme
side bindings we needed in certain situations.  This was a while back
(started years ago in fact), and before we fully realized how guile's
module system worked.  Switching to scm_c_module_ref (or other forms
of explicit lookup) makes it much clearer in the code what's actually
going on, and certainly makes it more likely to "do what we mean :>".
I think at least initially it can be easy to forget that on the C
side, there's no such thing as a lexical current-module.

In the cases I've run in to, one of the most common situations was
that the C code needed to look up a variable or function on the scheme
side and then use it.  In many cases the code *could* have been
rewritten to avoid the use of the C->scheme lookup, but in some cases
such a change would have made the code a lot more complex than
necessary.  Sometimes all you want is (this is definitely just
psuedo-code):

  void
  magic_button_callback ()
  {
    gh_call0(scm_c_module_lookup(..., "magic-button-callback"));
  }

  sometoolkit_button_attach_callback(button, magic_button_callback);

and in this case, maybe you *want* the button press to use whatever's
currently bound to 'magic-button-callback -- a-la emacs 'foo rather
than just what was bound when you attached the callback.  There are
defintely other ways you could handle this, but this seems pretty
straightforward...

FWIW

-- 
Rob Browning
rlb @defaultvalue.org, @linuxdevel.com, and @debian.org
Previously @cs.utexas.edu
GPG=1C58 8B2C FB5E 3F64 EA5C  64AE 78FE E5FE F0CB A0AD



reply via email to

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