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] |
On 26 Sep 1998, Jim Blandy wrote: > > 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? Well, you could - issue a more detailed error message with SCM_ASSERT - do some cleanup on the heap before actually raising the error - just provide a default value to perform the computation with You could even decide to perform the desired computation with guile's bignums. ...hm...think... Hey, that raises a good question: are guile's bignums accessible from the C level? If so, then there could also be a conversion gh_scm2bignum or similar. I think some days ago someone suggested that guile used some GNU bignum package. In this case, the user could provide two implementations: a fast one with C data types and a fallback with bignums. Best regards, Dirk Herrmann