unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Marius Vollmer <mvo@zagadka.ping.de>
Cc: guile-user@gnu.org
Subject: Re: [guile/scwm] SCM_HOOKP changed?
Date: 16 Sep 2002 01:59:21 +0200	[thread overview]
Message-ID: <87n0qin6sm.fsf@zagadka.ping.de> (raw)
In-Reply-To: <200209151501.24373.pieter.pareit@planetinternet.be>

P Pareit <pieter.pareit@planetinternet.be> writes:

> Hey,
> 
> I have a lot of code depending on SCM_HOOKP, has SCM_HOOKP changed
> in any way?  I also seen it is not documented, so I guess it should
> not be used, is scm_hook_p the right alternative?

No, the problem is something else.

SCM_HOOKP returns a C boolean, that is, either 0 or 1.  scm_hook_p
returns a Scheme boolean, either SCM_BOOL_F or SCM_BOOL_T (which are
both true in the C sense).

In your program belowe, error_hook is a variable, not a hook.  Both
SCM_HOOKP and scm_hook_p returne their variant of false, but you test
the return value of scm_hook_p in the wrong way.  You would have to
write

  if (SCM_FALSEP (scm_hook_p (error_hook)))
    ...

(Do not compare directly with SCM_BOOL_F since there might be other
false values, like scm_lisp_nil.)

The reason why error_hook is a variable is because scm_c_define
returns the variable that it has created or reused, not the value that
the variable is initialized with.

The best think to do is probably to use SCM_SNARF_HERE and
SCM_SNARF_INIT, like so:

  #define SCWM_GLOBAL_HOOK(var, name, args, docstring) \
   SCM_SNARF_HERE (SCM var) \
   SCM_SNARF_INIT ( \
     var = scm_permanent_object (scm_make_hook(SCM_MAKINUM(args))); \
     scm_c_define (name, var);)

Guile will support SCM_SNARF_HERE and SCM_SNARF_INIT, I think there is
no way around that.  When possibly, I'll also add
backwards-compatability for SCM__I, etc.

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


      parent reply	other threads:[~2002-09-15 23:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-15 13:01 [guile/scwm] SCM_HOOKP changed? P Pareit
2002-09-15 20:56 ` Thien-Thi Nguyen
2002-09-15 21:28   ` Thien-Thi Nguyen
2002-09-16  4:39     ` Thien-Thi Nguyen
2002-09-16  9:50     ` Marius Vollmer
2002-09-16 11:35       ` Thien-Thi Nguyen
2002-09-19 20:20         ` Neil Jerram
2002-09-15 23:59 ` Marius Vollmer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87n0qin6sm.fsf@zagadka.ping.de \
    --to=mvo@zagadka.ping.de \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).