guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Naming conventions of conversion routines


From: Daschbach, John L
Subject: Naming conventions of conversion routines
Date: Wed, 28 May 2003 11:30:54 -0700

I have been working to upgrade my guile C code to the new "scm_*" routines from 
the "gh_*" routines.  The new naming convention is more confusing than the gh 
convention.   Does anyone else find this so, and should it be changed?

For instance:

`gh_long2scm'
     Use `scm_long2num' instead.

`gh_double2scm'
     Use `scm_make_real' instead.

`gh_scm2long'
     Replace `gh_scm2long (OBJ)' by
          scm_num2long (OBJ, SCM_ARG1, STR)
     where STR is a C string that describes the context of the call.

`gh_scm2double'
     Replace `gh_scm2double (OBJ)' by
          scm_num2dbl (OBJ, STR)
     where STR is a C string that describes the context of the call.
With the gh convention it is clear that the return value is an SCM object, and 
without thinking one can write the conversion to and from C.  With the new 
convention we have

scm_make_real(NUMBER) <=> scm_num2dbl(OBJ,STR)

and

scm_long2num(NUMBER) <=> scm_num2long (OBJ, SCM_ARG1, STR)

When reading code it seems to me  more transparent to have "2scm" rather than 
"2num" and "make_real".  
The symetric naming of the gh system is more logical.  Why do we now have 
"scm_make_real" instead of "scm_double2num"?  Why does scm_num2long have three 
arguments with SCM_ARG1 and scm_num2dbl have two arguments?
Why is the new system inconsistent when the old one was not?  

The reason I started using guile some time back was to have a way to script 
mixed C and Fortran codes.  I found it easy to wrap these codes with guile and 
get values into and out of the C code from guile.  Mostly this used the gh_ 
interface.  Now gh_ is being depreceated, but the conversion routines between C 
and guile are not complete.  e.g.

`gh_scm2newstr'
     No direct scm equivalent.  [FIXME]

`gh_get_substr'
     No direct scm equivalent.  [FIXME]

`gh_symbol2newstr'
     No direct scm equivalent.  [FIXME]

`gh_scm2chars'
     No direct scm equivalent.  [FIXME]

`gh_scm2shorts' and `gh_scm2longs'
     No direct scm equivalent.  [FIXME]

`gh_scm2floats' and `gh_scm2doubles'
     No direct scm equivalent.  [FIXME]

This is causing me to think that the use of guile as a wrapper for C code is 
not important to the developers and there is a risk that this will not work in 
the future.  Is the use of guile as a wrapper for C code being depreceated?

-John





reply via email to

[Prev in Thread] Current Thread [Next in Thread]