Ann: SWI-Prolog 9.1.7

Dear SWI-Prolog user,

SWI-Prolog 9.1.7 is ready for download. Quite a couple of things happened,
some of which may impact compatibility in corner cases. Highlights:

  • det/1 had a bug where the property was not checked if a det
    predicate performs a last call to a different meta-predicate.
    This fix may result in errors in your program that previously
    remained silent.

  • C write-based conversion to text did not use character_escapes
    when doing quoted write. This is now consistent with term_term/2
    and friends. As a result, strings obtained this way will have
    e.g. \n rather than a newline. This also applies to
    term_to_atom/2, term_string/2, etc. May cause compatibility
    issues, notably if other languages process the output.

  • catch/3 now behaves as catch_with_backtrace/3 in debug mode. This
    improves the debugging experience for applications that catch
    exceptions a lot. This does rely on a modified location and
    an extra argument for user:prolog_exception_hook/4 to
    prolog:prolog_exception_hook/5.

  • call_time/3 now does full reification, including exceptions by
    returning throw(Exception) as result.

  • library(main) argv_options/3 now allows for optional long options
    by defining the type as a disjunction of boolean and some other
    type. This is used by library(http/http_unix_daemon) to switch
    to this commandline parser rather than doing the work ad-hoc.

  • Correct port counts for the profiler as long is there is no
    indirect recursion by @ridgeworks.

  • Added uri_edit/3 to modify a uri in a safe way. This can also start
    from scratch to create one from components.

  • Various new tricks for sweep emacs mode.

  • Support for Blowfish password encryption by @jamesnvc

  • Fixed several memory leaks.

  • Various documentation improvements, notable by @peter.ludemann.

    Enjoy — Jan

SWI-Prolog Changelog since version 9.1.6

  • STYLE: Updated library(dcg/basics) to use the current layout.

  • ADDED: library(dcg/basics): csym(?Atom) as <csymf><csym>*.

  • ADDED: argv_options/3: allow for optional long options by allowing
    for a boolean in the disjunctive type.

  • DOC: Clarify exceptions behavior

  • DOC: add a few background papers

  • FIXED: det/1 and friends to propagate the expectation in last calls
    to a meta predicate.

  • FIXED: XSB emulation no longer needs subseq/3 as that is now in our
    library(lists) as well.

  • TEST: Fixed tests to comply with
    e23c141be2f071b450f0d39981ac53251e1bd4f1 in debug mode.

  • MODIFIED: Writing \ quoted without character_escapes
    should not double the \. This bug was introduced
    with cbe691f8af61ccaf466147868a316b96c110fedb to “fix”
    term_to_atom('a\\b', A) to produce A = 'a\\b' (which is
    quoted again by the toplevel to produce A = '\'a\\\\b\''.
    The issue is that term_to_atom/2 using PL_write_term() with
    PL_WRT_QUOTED, but not PL_WRT_CHARESCAPES. There is now
    a new flag PL_WRT_NO_CHARESCAPES. If either flag is given, we
    explicitly enable or disable character escapes. If none is given,
    the behaviour depends on the global (module user) value of the
    character_escapes flag.

    This implies that e.g. term_to_atom('a\nb', A) used to produce a
    quoted atom with a plain newline, while in the new version the newline
    is escaped as \n.

    Many foreign libraries using PL_write_term() or PL_get_chars() using
    CVT_WRITE did not use character escapes while they do now. As long as
    the output is read by Prolog the result is the same.

  • FIXED: with_output_to/3: need to restore the streams while redirected
    to avoid leaking the stream handle because it remains referenced.

  • FIXED: tty_get_capability/3: memory leak.

  • FIXED: Memory leak in peek_string/3.

  • MODIFIED: Renamed exception processing hook
    user:prolog_exception_hook/4 into prolog:prolog_exception_hook/5,
    providing an additional argument that contains the current setting
    of the debug flag. Note that we cannot ask for this flag as the
    hook runs in “nodebug” mode. As the change is incompatible anyway,
    we also move the hook to the prolog module where the modern system
    hooks live. The new argument is used by library(prolog_stack) to make
    catch/3 behave as catch_with_backtrace/3 when in debug mode if the
    “guard” debug is defined (default). If this is not desired, use

    :- use_module(library(prolog_stack)).
    :- retractall(prolog_stack:guard(debug)).
    

    Code that use the old hook must rename the predicate and add the
    Debug
    argument. Code that wishes to be compatible with old and new
    Prolog can
    implement both hooks.

  • FIXED: error propagation of call_time/2 and updated docs.

  • MODIFIED: call_time/3 to not rethrow the exception but return it in
    the status reification as throw(Error).

  • ADDED: base64_encoded/3: added charset(openbsd), implementing the
    OpenBSD alphabet for base64 encoding Needed for bcrypt implementation
    in packages/ssl

  • FIXED: Provide (dummy) profiling interface for foreign code if
    profiling is not supported.

  • ENHANCED: explain/1 to report predicates as non-terminal if this
    is known.

  • ENHANCED: Use 64 bit counters for profiling.

  • FIXED: Issue#122: unification can create unsatisfyable or nodes.

  • ADDED: library(lists): subseq/3.

  • WASM: make prolog compatible with emsdk 3.1.31

  • FIXED: profiler port counts for redo and fail. Rather than trying
    to count redo, we now count fail and compute redo from call+redo =
    exit+fail. Note that a call can be matched with at most one fail.

  • ENHANCED: Small speedup for findall/3 by specializing
    setup_call_cleanup/3.

  • ENHANCED: Simplified implementation for the cleanup family,
    call_cleanup/2, setup_call_cleanup/3.

  • MODIFIED: Moved already deprecated call_cleanup/3 from the core to
    library(backcomp).

  • CLEANUP: The VM no longer needs to know the identify of
    setup_call_catcher_cleanup/4

Package clib

  • ADDED: uri_edit/3 to build or modify a URI from components.

  • FIXED: Memory leak in uri handling

Package http

  • ADDED: #158: Handle surrogate pairs in http/json The JSON string
    “\ud83d\udc95” has one codepoint, not two.

    This is because the spec allows extended characters to be
    encoded as a pair of 16-bit values, called a “surrogate pair”.

    From RFC 4627:

    To escape an extended character that is not in the Basic Multilingual
    Plane, the character is represented as a twelve-character sequence,
    encoding the UTF-16 surrogate pair. So, for example, a string
    containing only the G clef character (U+1D11E) may be represented as
    “\uD834\uDD1E”.

    This commit fixes the JSON parser to handle such surrogate pairs.

  • ENHANCED: library(http/http_unix_daemon) to use argv_options/3
    in guided mode. This simplifies adding options and defaults for
    applications using this library and simplifies maintenance.

  • FIXED: Possible non-determinism in write_html/2 on a mailbox that
    has not been posted to.

Package pldoc

  • FIXED: LaTeX backend: generating \url{} must escape #.

Package plunit

  • DOC: Sync recent changes into the LaTeX docs

Package semweb

  • FIXED: memory leak in Turtle parser in create/destroy cycle.

Package sgml

  • TEST: Free sgml parser and end of test to avoid a memory leak.

Package ssl

  • ADDED: crypto_password_hash/2,3 option algorithm(bcrypt) Uses the
    Openwall implementation of BCrypt, a public-domain, widely-used
    C implementation.

    Requires openbsd support from library(base64), added Feb 22 2023.

Package sweep

  • FIXED: beginning-of-clause detection with quoted head functors *
    sweeprolog.el (sweeprolog-beginning-of-top-term): don’t skip quoted
    functors in clause heads.

  • ADDED: Support setting breakpoints in sweeprolog-mode *
    sweep.pl (sweep_set_breakpoint/2) (sweep_delete_breakpoint/2)
    (sweep_set_breakpoint_condition/2): new predicates.

    • sweeprolog.el (sweeprolog-dependency-directive): update
      package-version field.
      (sweeprolog-set-breakpoint)
      (sweeprolog-set-breakpoint-condition)
      (sweeprolog-delete-breakpoint)
      (sweeprolog-list-breakpoints): new commands.
      (sweeprolog-highlight-breakpoints): new user option.
      (sweeprolog-mode-map): bind sweeprolog-set-breakpoint.

    • README.org (Setting Breakpoints): new manual section.

  • ADDED: mode line indication for loaded buffers *
    sweep.pl (sweep_source_file_load_time/2): new predicate.
    (sweep_load_buffer/2): also update source modification
    time based. * sweeprolog.el (sweeprolog-buffer-load-time)
    (sweeprolog-buffer-loaded-since-last-modification-p): new functions.
    (sweeprolog-load-buffer): use it. (sweeprolog-mode): add mode line
    indication if buffer is loaded.

  • MODIFIED: sweeprolog-update-dependencies choice of
    directives * sweeprolog.el (sweeprolog-dependency-directive):
    New user option. Determines which directive to use in…
    (sweeprolog-update-dependencies): Fix edge cases in finding where
    to insert new directives. Optionally infer directive to add based on
    current buffer contents.

    • README.org (Managing Dependencies): Update section.

Package xpce

  • UPDATED: Use renamed (to prolog:prolog_exception_hook/5) hook for
    trapping exceptions.
2 Likes