(guile.info.gz) scm transition summary
Info Catalog
(guile.info.gz) Mixing gh and scm APIs
(guile.info.gz) GH
19.14 Transitioning to the scm Interface
========================================
The following table summarizes the available information on how to
transition from the GH to the scm interface. Where transitioning is not
completely straightforward, the table includes a reference to more
detailed documentation in the preceding sections.
Header file
Use `#include <libguile.h>' instead of `#include <guile/gh.h>'.
Compiling and Linking
Use `guile-config' to pick up the flags required to compile C or
C++ code that uses `libguile', like so
$(CC) -o prog.o -c prog.c `guile-config compile`
If you are using libtool to link your executables, just use
`-lguile' in your link command. Libtool will expand this into the
needed linker options automatically. If you are not using
libtool, use the `guile-config' program to query the needed
options explicitly. A linker command like
$(CC) -o prog prog.o `guile-config link`
should be all that is needed. To link shared libraries that will
be used as Guile Extensions, use libtool to control both the
compilation and the link stage.
The `SCM' type
No change: the scm interface also uses this type to represent an
arbitrary Scheme value.
`SCM_BOOL_F' and `SCM_BOOL_T'
No change.
`SCM_UNSPECIFIED' and `SCM_UNDEFINED'
No change.
`gh_enter'
Use `scm_boot_guile' instead, but note that `scm_boot_guile' has a
slightly different calling convention from `gh_enter':
`scm_boot_guile', and the main program function that you specify
for `scm_boot_guile' to call, both take an additional CLOSURE
parameter. Guile Initialization Functions for more
details.
`gh_repl'
Use `scm_shell' instead.
`gh_init'
Use `scm_init_guile' instead.
`gh_eval_str'
Use `scm_c_eval_string' instead.
`gh_eval_file' or `gh_load'
Use `scm_c_primitive_load' instead.
`gh_new_procedure'
Use `scm_c_define_gsubr' instead, but note that the arguments are
in a different order: for `scm_c_define_gsubr' the C function
pointer is the last argument. A Sample Guile Extension
for an example.
`gh_defer_ints' and `gh_allow_ints'
Use `SCM_DEFER_INTS' and `SCM_ALLOW_INTS' instead. Note that
these macros are used without parentheses, as in `SCM_DEFER_INTS;'.
`gh_bool2scm'
Use `SCM_BOOL' instead.
`gh_ulong2scm'
Use `scm_ulong2num' instead.
`gh_long2scm'
Use `scm_long2num' instead.
`gh_double2scm'
Use `scm_make_real' instead.
`gh_char2scm'
Use `SCM_MAKE_CHAR' instead.
`gh_str2scm'
Use `scm_mem2string' instead.
`gh_str02scm'
Use `scm_makfrom0str' instead.
`gh_set_substr'
No direct scm equivalent. [FIXME]
`gh_symbol2scm'
Use `scm_str2symbol' instead. [FIXME: inconsistent naming, should
be `scm_str02symbol'.]
`gh_ints2scm' and `gh_doubles2scm'
No direct scm equivalent. [FIXME]
`gh_chars2byvect' and `gh_shorts2svect'
No direct scm equivalent. [FIXME]
`gh_longs2ivect' and `gh_ulongs2uvect'
No direct scm equivalent. [FIXME]
`gh_floats2fvect' and `gh_doubles2dvect'
No direct scm equivalent. [FIXME]
`gh_scm2bool'
Use `SCM_NFALSEP' instead.
`gh_scm2int'
Replace `gh_scm2int (OBJ)' by
scm_num2int (OBJ, SCM_ARG1, STR)
where STR is a C string that describes the context of the call.
`gh_scm2ulong'
Replace `gh_scm2ulong (OBJ)' by
scm_num2ulong (OBJ, SCM_ARG1, STR)
where STR is a C string that describes the context of the call.
`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.
`gh_scm2char'
Use the `SCM_CHAR' macro instead, but note that `SCM_CHAR' does
not check that its argument is actually a character. To check that
a `SCM' value is a character before using `SCM_CHAR' to extract
the character value, use the `SCM_VALIDATE_CHAR' macro.
`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]
`gh_boolean_p'
Use the `SCM_BOOLP' macro instead, or replace `gh_boolean_p (OBJ)'
by
SCM_NFALSEP (scm_boolean_p (OBJ))
`gh_symbol_p'
Use the `SCM_SYMBOLP' macro instead, or replace `gh_symbol_p
(OBJ)' by
SCM_NFALSEP (scm_symbol_p (OBJ))
`gh_char_p'
Use the `SCM_CHARP' macro instead, or replace `gh_char_p (OBJ)' by
SCM_NFALSEP (scm_char_p (OBJ))
`gh_vector_p'
Use the `SCM_VECTORP' macro instead, or replace `gh_vector_p
(OBJ)' by
SCM_NFALSEP (scm_vector_p (OBJ))
`gh_pair_p'
Use the `SCM_CONSP' macro instead, or replace `gh_pair_p (OBJ)' by
SCM_NFALSEP (scm_pair_p (OBJ))
`gh_number_p'
Use the `SCM_NUMBERP' macro instead, or replace `gh_number_p
(OBJ)' by
SCM_NFALSEP (scm_number_p (OBJ))
`gh_string_p'
Use the `SCM_STRINGP' macro instead, or replace `gh_string_p
(OBJ)' by
SCM_NFALSEP (scm_string_p (OBJ))
`gh_procedure_p'
Replace `gh_procedure_p (OBJ)' by
SCM_NFALSEP (scm_procedure_p (OBJ))
`gh_list_p'
Replace `gh_list_p (OBJ)' by
SCM_NFALSEP (scm_list_p (OBJ))
`gh_inexact_p'
Use the `SCM_INEXACTP' macro instead, or replace `gh_inexact_p
(OBJ)' by
SCM_NFALSEP (scm_inexact_p (OBJ))
`gh_exact_p'
Replace `gh_exact_p (OBJ)' by
SCM_NFALSEP (scm_exact_p (OBJ))
`gh_eq_p'
Use the `SCM_EQ_P' macro instead, or replace `gh_eq_p (X, Y)' by
SCM_NFALSEP (scm_eq_p (X, Y))
`gh_eqv_p'
Replace `gh_eqv_p (X, Y)' by
SCM_NFALSEP (scm_eqv_p (X, Y))
`gh_equal_p'
Replace `gh_equal_p (X, Y)' by
SCM_NFALSEP (scm_equal_p (X, Y))
`gh_string_equal_p'
Replace `gh_string_equal_p (X, Y)' by
SCM_NFALSEP (scm_string_equal_p (X, Y))
`gh_null_p'
Use the `SCM_NULLP' macro instead, or replace `gh_null_p (OBJ)' by
SCM_NFALSEP (scm_null_p (OBJ))
`gh_cons'
Use `scm_cons' instead.
`gh_car' and `gh_cdr'
Use the `SCM_CAR' and `SCM_CDR' macros instead.
`gh_cxxr' and `gh_cxxxr'
(Where each x is either `a' or `d'.) Use the corresponding
`SCM_CXXR' or `SCM_CXXXR' macro instead.
`gh_set_car_x' and `gh_set_cdr_x'
Use `scm_set_car_x' and `scm_set_cdr_x' instead.
`gh_list'
Use `scm_listify' instead.
`gh_length'
Replace `gh_length (LST)' by
scm_num2ulong (scm_length (LST), SCM_ARG1, STR)
where STR is a C string that describes the context of the call.
`gh_append'
Use `scm_append' instead.
`gh_append2', `gh_append3', `gh_append4'
Replace `gh_appendN (L1, ..., LN)' by
scm_append (scm_listify (L1, ..., LN, SCM_UNDEFINED))
`gh_reverse'
Use `scm_reverse' instead.
`gh_list_tail' and `gh_list_ref'
Use `scm_list_tail' and `scm_list_ref' instead.
`gh_memq', `gh_memv' and `gh_member'
Use `scm_memq', `scm_memv' and `scm_member' instead.
`gh_assq', `gh_assv' and `gh_assoc'
Use `scm_assq', `scm_assv' and `scm_assoc' instead.
`gh_make_vector'
Use `scm_make_vector' instead.
`gh_vector' or `gh_list_to_vector'
Use `scm_vector' instead.
`gh_vector_ref' and `gh_vector_set_x'
Use `scm_vector_ref' and `scm_vector_set_x' instead.
`gh_vector_length'
Use the `SCM_VECTOR_LENGTH' macro instead.
`gh_apply'
Use `scm_apply' instead, but note that `scm_apply' takes an
additional third argument that you should set to `SCM_EOL'.
Info Catalog
(guile.info.gz) Mixing gh and scm APIs
(guile.info.gz) GH
automatically generated byinfo2html