Next: , Previous: GH deprecation, Up: GH


5.22.2 Transitioning away from GH

The following table summarizes how to transition from the GH to the scm interface. The replacements that are recommended are not always completely equivalent to the GH functionality that they should replace. Therefore, you should read the reference documentation of the replacements carefully if you are not yet familiar with them.

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_catch
Use scm_internal_catch instead.
gh_eval_str
Use scm_c_eval_string instead.
gh_eval_str_with_catch
Use scm_c_eval_string together with scm_internal_catch instead.
gh_eval_str_with_standard_handler
Use scm_c_eval_string together with scm_internal_catch and scm_handle_by_message_no_exit instead.
gh_eval_str_with_stack_saving_handler
Use scm_c_eval_string together with scm_internal_stack_catch and scm_handle_by_message_no_exit instead.
gh_eval_file or gh_load
Use scm_c_primitive_load instead.
gh_eval_file_with_catch
Use scm_c_primitive_load together with scm_internal_catch instead.
gh_eval_file_with_standard_handler
Use scm_c_primitive_load together with scm_internal_catch and scm_handle_by_message_no_exit instead.
gh_new_procedure
gh_new_procedure0_0
gh_new_procedure0_1
gh_new_procedure0_2
gh_new_procedure1_0
gh_new_procedure1_1
gh_new_procedure1_2
gh_new_procedure2_0
gh_new_procedure2_1
gh_new_procedure2_2
gh_new_procedure3_0
gh_new_procedure4_0
gh_new_procedure5_0
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_CRITICAL_SECTION_START and SCM_CRITICAL_SECTION_END instead. Note that these macros are used without parentheses, as in SCM_DEFER_INTS;.
gh_bool2scm
Use scm_from_bool instead.
gh_int2scm
Use scm_from_int instead.
gh_ulong2scm
Use scm_from_ulong instead.
gh_long2scm
Use scm_from_long instead.
gh_double2scm
Use scm_make_real instead.
gh_char2scm
Use SCM_MAKE_CHAR instead.
gh_str2scm
Use scm_from_locale_stringn instead.
gh_str02scm
Use scm_from_locale_string instead.
gh_set_substr
Use scm_string_copy_x.
gh_symbol2scm
Use scm_from_locale_symbol instead.
gh_ints2scm
gh_doubles2scm
gh_chars2byvect
gh_shorts2svect
gh_longs2ivect
gh_ulongs2uvect
gh_floats2fvect
gh_doubles2dvect
Use the uniform numeric vector function, See Uniform Numeric Vectors.
gh_scm2bool
Use scm_is_true or scm_to_bool instead.
gh_scm2int
Use scm_to_int instead.
gh_scm2ulong
Use scm_to_ulong instead.
gh_scm2long
Use scm_to_long instead.
gh_scm2double
Use scm_to_double instead.
gh_scm2char
Use scm_to_char instead.
gh_scm2newstr
Use scm_to_locale_string or similar instead.
gh_get_substr
Use scm_c_substring together with scm_to_locale_string or similar instead.
gh_symbol2newstr
Use scm_symbol_to_string together with scm_to_locale_string or similar instead.
gh_scm2chars
Use scm_from_locale_string (or similar) or the uniform numeric vector functions (see Uniform Numeric Vectors) instead.
gh_scm2shorts
gh_scm2longs
gh_scm2floats
gh_scm2doubles
Use the uniform numeric vector function, See Uniform Numeric Vectors.
gh_boolean_p
Use scm_is_bool instead.
gh_symbol_p
Use scm_is_symbol instead.
gh_char_p
Replace gh_char_p (obj) with
          scm_is_true (scm_char_p (obj))
     

gh_vector_p
Replace gh_vector_p (obj) with
          scm_is_true (scm_vector_p (obj))
     

gh_pair_p
Replace gh_pair_p (obj) with
          scm_is_true (scm_pair_p (obj))
     

gh_number_p
Use scm_is_number instead.
gh_string_p
Use scm_is_string instead.
gh_procedure_p
Replace gh_procedure_p (obj) by
          scm_is_true (scm_procedure_p (obj))
     

gh_list_p
Replace gh_list_p (obj) with
          scm_is_true (scm_list_p (obj))
     

gh_inexact_p
Replace gh_inexact_p (obj) with
          scm_is_true (scm_inexact_p (obj))
     

gh_exact_p
Replace gh_exact_p (obj) with
          scm_is_true (scm_exact_p (obj))
     

gh_eq_p
Use scm_is_eq instead.
gh_eqv_p
Replace gh_eqv_p (x, y) with
          scm_is_true (scm_eqv_p (x, y))
     

gh_equal_p
Replace gh_equal_p (x, y) with
          scm_is_true (scm_equal_p (x, y))
     

gh_string_equal_p
Replace gh_string_equal_p (x, y) with
          scm_is_true (scm_string_equal_p (x, y))
     

gh_null_p
Use scm_is_null instead.
gh_not
Use scm_not instead.
gh_make_string
Use scm_make_string instead.
gh_string_length
Use scm_string_length instead.
gh_string_ref
Use scm_string_ref instead.
gh_string_set_x
Use scm_string_set_x instead.
gh_substring
Use scm_substring instead.
gh_string_append
Use scm_string_append instead.
gh_cons
Use scm_cons instead.
gh_car and gh_cdr
Use scm_car and scm_cdr instead.
gh_cxxr and gh_cxxxr
(Where each x is either `a' or `d'.) Use the corresponding scm_cxxr or scm_cxxxr function 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_list_n instead.
gh_length
Replace gh_length (lst) with
          scm_to_size_t (scm_length (lst))
     

gh_append
Use scm_append instead.
gh_append2, gh_append3, gh_append4
Replace gh_appendN (l1, ..., lN) by
          scm_append (scm_list_n (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 scm_c_vector_length instead.
gh_uniform_vector_length
Use scm_c_uniform_vector_length instead.
gh_uniform_vector_ref
Use scm_c_uniform_vector_ref instead.
gh_vector_to_list
Use scm_vector_to_list instead.
gh_apply
Use scm_apply_0 instead.
gh_call0
gh_call1
gh_call2
gh_call3
Use scm_call_0, scm_call_1, etc instead.
gh_display
gh_write
gh_newline
Use scm_display (obj, scm_current_output_port ()) instead, etc.
gh_lookup
Use scm_variable_ref (scm_c_lookup (name)) instead.
gh_module_lookup
Use scm_variable_ref (scm_c_module_lookup (module, name)) instead.