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

Returning status from C functions


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 



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]