[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Real predicate in C
From: |
Marius Vollmer |
Subject: |
Re: Real predicate in C |
Date: |
19 Jun 2002 13:30:05 +0200 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 |
Hilaire Fernandes <address@hidden> writes:
> It looks like the real? predicate is not implemented in the C interface,
> I got the following error when trying to use it:
>
> drgeo_script.cc:141: implicit declaration of function `int gh_real_p(...)'
The 'real?' predicate is available from the scm_ interface, but not
from the gh_ interface.
You can use
SCM_NFALSEP (scm_real_p (OBJ))
to test whether OBJ is a real number. (Note that integers are real too.)
The funny SCM_NFALSEP means "not false?" and must be used since
scm_real_p returns a Scheme boolean (that is, either #t or #f) and not
a C boolean (either 1 or 0).
The SCM_REALP macro only tests whether some number has a floating
point representation, it is not the same as scm_real_p.
(We are not really happy about this situation, either.)
In general, the 'primitive procedures' of the Scheme side are all
available on the C side, in the scm_ interface. The Guile reference
manual talks about this in the "API overview" node.
For example, 'real?' is a primitive procedure and its C name is
"scm_real_p". It takes one SCM argument and returns a SCM result.
You can check whether it is a primitive by printing it from the repl:
guile> real?
#<primitive-procedure real?>
guile> (define (foo) #t)
guile> foo
#<procedure foo ()>