This is the mail archive of the guile@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]

Re: Additions to the gh_ interface.



> I just realized, that the R*RS predicates complex?, real?, rational? and
> integer? don't have an C equivalent. These are probably easily provided.

... right ... C code needs decent access to numbers.

> However, there is also need for a test, whether a Scheme number is
> convertible to a C builtin number type. I assume that such a test will
> only be required in combination with the actual conversion. Therefore, I
> suggest the following solution: 
> 
> long gh_scm2long(SCM obj);                /* the current function */
> 
> long gh_safe_scm2long(SCM obj, int* flags);   /* the new function */
> 
> The status of the conversion could be returned in the flags variable.
> (Instead of int, an enumeration could be used, or a typedef, ...)

Hmm... that's an idea.  The conversion process does produce the
information that you want to put into *FLAGS, as a side effect.
Granted that Guile should provide some way to discover whether a
Scheme number can be accurately converted to a particular C type, is
this the best interface?  What would you do if you got an OVERFLOW,
besides raise an error?