9.1.5 Foreign Language APIs

9.1.5.1 Foreign Language Interface

The conversion specifier (in foreign/[2,3] facts) string(N) has been dropped.

The conversion specifier chars has been renamed to codes, in analogy with the built-in predicate atom_codes/2, the second argument of which is a list of character codes.

The C header generated by splfr from the foreign/[2,3] facts now uses the const attribute where appopriate.

Foreign resources are no longer unloaded by save_program/[1,2]. For this reason, the deinit function of a foreign resource is no longer called when saving a program so SP_WHEN_SAVE has been removed.

9.1.5.2 C API Functions

Many functions in the C API has been changed or removed, especially those related to OS and I/O operations. There are also a number of new C API functions.

Old API Replaced by


SP_make_stream, SP_make_stream_context SP_create_stream


SP_set_tty SP_CREATE_STREAM_OPTION_INTERACTIVE


SP_fgetc SP_get_byte, SP_get_code


SP_fputc SP_put_byte, SP_put_code


SP_fputs SP_put_codes, SP_put_encoded_string


SP_fflush SP_flush_output


SP_chdir SP_set_current_dir


SP_getcwd SP_get_current_dir


SP_set_wcx_hooks Gone


SP_wcx_getc, SP_wcx_putc Gone


SP_to_os, SP_from_os Gone


SP_put_number_chars SP_put_number_codes


SP_get_number_chars SP_get_number_codes

Other new functions include:

SP_get_stream_user_data
SP_get_stream_counts
SP_put_bytes
SP_fopen
SP_unget_code
SP_unget_byte
Also, many functions take new or changed parameters.
9.1.5.3 Java API

Send feedback on this subject.