unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Real predicate in C
@ 2002-06-09 11:09 Hilaire Fernandes
  2002-06-18 22:02 ` Hilaire Fernandes
  2002-06-19 11:30 ` Marius Vollmer
  0 siblings, 2 replies; 6+ messages in thread
From: Hilaire Fernandes @ 2002-06-09 11:09 UTC (permalink / raw)


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 number? one is implemented but I need to test for real number and complex.

Any tips?

Hilaire

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Real predicate in C
  2002-06-09 11:09 Real predicate in C Hilaire Fernandes
@ 2002-06-18 22:02 ` Hilaire Fernandes
  2002-06-19  4:47   ` Steve Tell
  2002-10-04 18:02   ` Thien-Thi Nguyen
  2002-06-19 11:30 ` Marius Vollmer
  1 sibling, 2 replies; 6+ messages in thread
From: Hilaire Fernandes @ 2002-06-18 22:02 UTC (permalink / raw)
  Cc: guile-user

If the gh_real predicate does not exist, what is the proper way to implement it?

Hilaire

On Sun, 9 Jun 2002 13:09:20 +0200
Hilaire Fernandes <hilaire@ext.cri74.org> wrote:

> 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 number? one is implemented but I need to test for real number and complex.
> 
> Any tips?
> 
> Hilaire
> 
> _______________________________________________
> Guile-user mailing list
> Guile-user@gnu.org
> http://mail.gnu.org/mailman/listinfo/guile-user
> 

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Real predicate in C
  2002-06-18 22:02 ` Hilaire Fernandes
@ 2002-06-19  4:47   ` Steve Tell
  2002-06-19 11:41     ` Marius Vollmer
  2002-10-04 18:02   ` Thien-Thi Nguyen
  1 sibling, 1 reply; 6+ messages in thread
From: Steve Tell @ 2002-06-19  4:47 UTC (permalink / raw)
  Cc: guile-user

On Wed, 19 Jun 2002, Hilaire Fernandes wrote:

> If the gh_real predicate does not exist, what is the proper way to implement it?

Try:
	SCM_REALP(scmobj)

Unfortunately, it looks like the only way to learn this is to read
<libguile/numbers.h> (and ignore lots of implementation details).

Or just maybe my last download from http://www.glug.org/docbits/ is too
old.

Steve


> Hilaire
> 
> On Sun, 9 Jun 2002 13:09:20 +0200
> Hilaire Fernandes <hilaire@ext.cri74.org> wrote:
> 
> > 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 number? one is implemented but I need to test for real number and complex.
> > 
> > Any tips?
> > 
> > Hilaire
> > 
> > _______________________________________________
> > Guile-user mailing list
> > Guile-user@gnu.org
> > http://mail.gnu.org/mailman/listinfo/guile-user
> > 
> 
> _______________________________________________
> Guile-user mailing list
> Guile-user@gnu.org
> http://mail.gnu.org/mailman/listinfo/guile-user
> 

-- 
--
Steve Tell  tell@telltronics.org 


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Real predicate in C
  2002-06-09 11:09 Real predicate in C Hilaire Fernandes
  2002-06-18 22:02 ` Hilaire Fernandes
@ 2002-06-19 11:30 ` Marius Vollmer
  1 sibling, 0 replies; 6+ messages in thread
From: Marius Vollmer @ 2002-06-19 11:30 UTC (permalink / raw)
  Cc: guile-user

Hilaire Fernandes <hilaire@ext.cri74.org> 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 ()>

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Real predicate in C
  2002-06-19  4:47   ` Steve Tell
@ 2002-06-19 11:41     ` Marius Vollmer
  0 siblings, 0 replies; 6+ messages in thread
From: Marius Vollmer @ 2002-06-19 11:41 UTC (permalink / raw)
  Cc: Hilaire Fernandes, guile-user

Steve Tell <tell@telltronics.org> writes:

> On Wed, 19 Jun 2002, Hilaire Fernandes wrote:
> 
> > If the gh_real predicate does not exist, what is the proper way to implement it?
> 
> Try:
> 	SCM_REALP(scmobj)

That's unfortunately not the same as 'real?' in Scheme.  It is only
true for numbers represented as floating point, but is false for
integers, for example.  Yes, it's a mess.

> Unfortunately, it looks like the only way to learn this is to read
> <libguile/numbers.h> (and ignore lots of implementation details).

The manual has scm_real_p right next to 'real?'.

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Real predicate in C
  2002-06-18 22:02 ` Hilaire Fernandes
  2002-06-19  4:47   ` Steve Tell
@ 2002-10-04 18:02   ` Thien-Thi Nguyen
  1 sibling, 0 replies; 6+ messages in thread
From: Thien-Thi Nguyen @ 2002-10-04 18:02 UTC (permalink / raw)
  Cc: guile-user

   From: Hilaire Fernandes <hilaire@ext.cri74.org>
   Date: Wed, 19 Jun 2002 00:02:15 +0200

   If the gh_real predicate does not exist, what is the proper
   way to implement it?

the proper way to implement it is to add a few lines to
libguile/gh_predicates.c, libguile/gh.h, and add a mention
in the docs.  would you like to do this?  (in 1.4.x series,
gh_ is not deprecated so extending it compatibly is DTRT.)

thi


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-10-04 18:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-09 11:09 Real predicate in C Hilaire Fernandes
2002-06-18 22:02 ` Hilaire Fernandes
2002-06-19  4:47   ` Steve Tell
2002-06-19 11:41     ` Marius Vollmer
2002-10-04 18:02   ` Thien-Thi Nguyen
2002-06-19 11:30 ` Marius Vollmer

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).