This is the mail archive of the
guile@sources.redhat.com
mailing list for the Guile project.
Returning status from C functions
- To: guile at sourceware dot cygnus dot com
- Subject: Returning status from C functions
- From: Ian Grant <Ian dot Grant at cl dot cam dot ac dot uk>
- Date: Wed, 26 Jul 2000 15:18:30 +0100
- cc: Ian dot Grant at cl dot cam dot ac dot uk
Hello all,
Can seasoned Scheme people give their opinions on these two approaches to
returning status from C functions.
I have a library function, func - say, that returns status as an integer. In
the header file, as usual, there is a set of #defines allowing me to write
if (func() != FUNC_OK) .. etc
When I wrap this for guile, I could either return symbols FUNC_OK,
FUNC_FAILED_THIS_WAY, FUNC_FAILED_ANOTHER_WAY etc, or I could scm_sysintern
integers like
scm_sysintern("FUNC_OK", SCM_MAKINUM(FUNC_OK));
and have my wrapper return scheme integers.
Which is better? Thi points out that symbols can be used in a case statement
and the integer definition of FUNC_OK can't. On the other hand I can see uses
for the integer value. Of course it's easy to convert from one to the other
too - but which should be the default?
Thanks in anticipation.
Ian
--
Ian Grant, Computer Lab., New Museums Site, Pembroke Street, Cambridge
Phone: +44 1223 334420 Personal e-mail: iang at pobox dot com