Documentation of PL_put_term_from_chars() and PL_chars_to_term()


As I was browsing the extensive set of functions of the foreign prolog interface, I got confused about the difference, between PL_put_term_from_chars() and PL_chars_to_term().

Finally, checking the source code cleared it up.

Maybe it would be good to point out in the documentation that PL_chars_to_term() is just a version of PL_put_term_from_chars() with some default arguments.

PL_chars_to_term(const char *s, term_t t)
{ return PL_put_term_from_chars(t, REP_ISO_LATIN_1, (size_t)-1, s);

Updated. Thanks. Due to historical reasons most of the text handling functions come in three flavours: handling a nul-terminated ISO Latin 1 string, handling the same with a length to allow for nul characters and one with flags that specify the encoding and often type (atom/string/codes/chars), buffering and error handling. That reflects how text handling in Prolog evolved.

I guess new code should use the last family for most of the work. The others won’t be deleted, but it might be a good idea to move them to a dedicated section of the manual at some point.