Ann: SWI-Prolog 8.4.2 (stable)

Dear SWI-Prolog user,

A new stable version of SWI-Prolog, 8.4.2, is ready for download. This
backports most changes that have no or defendable compatibilitty impact.
Most changes address portability issues and a couple of crashes. The
main incompatible changes are listed below.

  • The MacOS bundle is now a universal binary that runs
    on Intel Macs and M1 (Silicon) Macs. Recent changes for
    dealing with locale (language) and start directory are included.

  • print_term/1,2 has many enhancements and fixes. Output may thus
    be different.

  • The write_term/3 option brace_terms behavior was the inverse
    of the documentation. This is fixed. Code using this feature
    must be updated.

  • For foreign code, qid_t is now a void* rather than intptr_t.
    As the have the same width, binaries are compatible. Source code
    using intptr_t instead of qid_t compiles correctly, but with
    a warning.

  • Foreign code using PL_prof_type_t may need to be updated for
    changes to this structure. It is unlikely there is any other
    usage for this than xpce.

    Enjoy — Jan

SWI-Prolog Changelog since version 8.4.1

  • FIXED: Tracer retry on a parent frame. Notably causes problems if
    retrying runs cleanup handlers.

  • MODIFIED: MacOS working directory and locale setup.

  • MODIFIED: MacOS swipl-win to start in ~/Documents.

  • MODIFIED: MacOS: set LC_CTYPE to UTF-8 if neither LANG nor LC_CTYPE is
    set. Also set the encoding flag to utf8 if LC_CTYPE is set to

  • PORT: Started Apple specific predicates. Adds

  • PORT: Fix compilation using clang in debug mode.

  • FIXED: make/0 to consider a file modified if some indirectly included
    file is modified. Used to only consider directly included files.

  • FIXED: Possible GC crash on a rational number appearing in a clause

  • FIXED: Indexing issue for assessing possible clauses indexes in SSU
    code. Can lead false “No matching clauses” errors.

  • DOC: read_string/3: clarify characters.

  • COMPAT: format/2: a numeric argument to ~s, e.g., ~3s truncates
    the string to the given number of characters.

  • COMPAT: format/2: ~r uses default radix of 8, compatible with SICStus
    and GNU-Prolog (used to raise an exception). Paulo Moura.

  • FIXED: set_prolog_flag(threads, Val) deadlocked. Paulo Moura.

  • FIXED: big integers constants in arithmetic expressions under
    optimization could be compiled as A_MPQ (rational), resulting in
    a crash. Paulo Moura.

  • DOC: further enhancement to untable/1 docs.

  • DOC: document the role of untable/1.

  • ADDED: foldsubterms/5 and use this to bootstrap foldsubterms/4,
    mapsubterms/3 and mapsubterms_var/3.

  • ENHANCED: print_term/1,2: actually handle the left_margin option
    (fix) and make its default the current column.

  • FIXED: print_term/1,2: avoid dependency on library(backcomp).

  • FIXED: call_residue_vars/2: if GC performs early reset on an attvar
    it is incorrectly considered residual.

  • DOC: Fixed PL_get_dict_key() docs. Matthijs van Otterdijk.

  • ENHANCED: Use mallinfo2 when available. By @mgodan1.

  • DOC: Fixed error in CMake build script for the manual.

  • DOC: Fixed LaTeX errors.

  • FIXED: Another postfix operator issue as a regression to recent fixes
    on postfix operator handling. Affects the R interface (reported
    by Nicos Angelopoulos for real, but probably rserve_client is also

  • DOC: clarify module issues wrt. macro expansion and explain what is
    affected by import modules.

  • DOC: read_term/2: quasi quotation layout

  • TEST: read_term/2 subterm_position option. Contributed by Peter

  • FIXED: Possible crash in copy_term/4 and copy_term_nat/4.

  • ADDED: copy_term/4 and copy_term_nat/4. These predicates provide a
    partial renaming of variables and is used in s(CASP). This patch also
    improves out-of-memory handling and adds a test suit for copy_term.

  • PORT: Added missing include for <errno.h>

  • ADDED: mapsubterms_var/3 as an alternative to mapsubterms/3 that also
    maps variables.

  • ENHANCED: If a package is available both globally and locally (per
    user), ignore the global one silently rather than with a warning.

  • ADDED: pack_install/2: option global(Boolean) to explicitly install
    a package for the user or globally.

  • BUILD: Include debug info with PGO build.

  • CMAKE: let Threads use -pthread instead of -lpthread This can link
    other needed libraries, and fix building on riscv64.

  • FIXED: Avoid warnings about uncaught exceptions from write_length/3
    in print_term/2.

  • ENHANCED: Edits commit 18690d80fbdc842a5bad3da1fb81a083e55b1b24.
    Forgotten amend and already pushed to origin.

  • FIXED: qsave_program/2: add missing load_module for shlib The
    predicate current_foreign_library is used which is from the module
    shlib. Unfortunately it is not imported though, which makes it
    impossible to use qsave without autoloading enabled.

    [edited by JW: use autoload/2 and also deal with autoload_all/1

  • TEST: Started a few operator tests

  • FIXED: handling postfix operators must reduce the left side before
    reducing the postfix operator.

  • ENHANCED: Issue#24: clause_info/4: reject if term layout returned
    by expand_term/4 is bogus. This forces the guitracer to revert to

  • FIXED: arg xf xf (cascading postfix operators) where the priority
    of the first is higher than the second must generate a syntax error
    rather than an incorrect term.

  • DEBUG: Fixed duplicate debug id

  • FIXED: print_term/2 handling of postfix operators.

  • SECURITY: running plain swipl loads from the current
    directory if this file exists. It is not advised to load customisation
    files from the current directory. We now only load when
    explicitly called using swipl -f while an implicit init file
    is only loaded from the user_app_config path alias.

  • DOC: foreach/2 by @swi

  • FIXED: SWISH Issue#146: failure to render stacktrace due to failure
    of message_to_string/2 on ansi(Style, Fmt, Arg) if Arg is not a list.

  • MODIFIED: Query identifiers now keep track of the engine to which they
    are associated. As a result, they are now anonymous pointers rather than
    (pointer wide) integers. Does not affect compatibility except source
    compatibility when the value is combined with integral types.

  • BUILD: Disable MQI if multi-threading is not enabled.

  • FIXED: print_term/2 from entering a loop. Also fixes unneeded
    parenthesis in lists.

  • FIXED: finding clauses from a source location could crash on thread
    local predicates

  • FIXED: print_term/2: respect write options when computing with of
    native output.

  • MODIFIED: print_term/2 to get the default right margin from tty_size
    if the output is a tty and tty_size/2 succeeds.

  • FIXED: We must preserve the pack registration when creating a saved
    state to make loading foreign resources work.

  • ENHANCED: main/0 to avoid setting up application signal handling and
    termination when run interactively.

  • FIXED: Issue#917: separate S_DYNAMIC and S_MULTIFILE. Jos de Roo.

  • ADDED: print_term/2: options fullstop(Boolean) and nl(Bool). Also lots
    of documentation restyling and removed old conditional compilation.

  • ENHANCED: print_term/2 to deal with operator expressions that exceed
    the line width.

  • FIXED: print_term/2: max priority of list elements and compound term
    arguments to 999 to force parenthesis.

  • FIXED: Issue#917: WAM Table mismatch: wam_table[119(s_static)] ==

  • FIXED: Ensure VMI instruction are on unique addresses. This patch
    extends 7bf463db4dcc7b4e27c820ef8fc6f94fd8116720 for the case that
    two VMIs jump to the same real implementation.

  • PORT: Guarantee two VM instructions are not optimized to use the
    same code.

  • FIXED: Ensure bigints are properly indexed on 32-bit platforms.

  • PORT: On MacOS fat executables, both try fat-darwin and the actual
    archirecture when searching foreign resources.

  • PORT: Set archirecture name of fat packages to fat.

  • PORT: Support generation of MacOS universal (fat) binaries.
    Also updates minimum supported MacOS version to 10.14.

  • PORT: Dynamically determine actual architecture on MacOS

  • PORT: Install openssl.cnf with MacOS dependencies

  • PORT: By default disable tcmalloc for MacOS as it causes a crash in
    setlocale() for Monterey.

  • ENHANCED: explain/1: hide system references.

  • PORT: Building an apple bundle using Qt6

  • PORT: Updated script for MacOS dependencies

  • DOC: return type for PL_put_variable(), PL_put_bool() and PL_put_atom()
    is int.

  • FIXED: Handle new terminal hyperlink elements in message_to_string/2

  • PORT: MacOS to deal with installation directory for libjpeg as
    installed by Macports. This patch also disables more Macports and
    Homebrew locations if we provide our own dependencies.

  • BUILD: By default use Macports gcc11 (gcc-mp-11)

  • EHNANCED: SICStus datime/2 emulation now supports mode datime(-When,

  • ADDED: random_subseq/3 and random_numlist/4 to
    library(random). Compatible with SICStus.

  • PORT: Fixed cmake issue for MacOS Homebrew dependencies.

  • DOC: edit/0.

  • FIXED: thread_update/2 when no change is made to the target module
    should still wakeup.

  • ADDED: prolog_choice_attribute/3: clause attribute to find the next
    candidate clause.

  • FIXED: Initial value for the Prolog flat on_warning must be print.

  • FIXED: Stack trace line-level location when parenthesis are used.

  • MODIFIED: write_term/3 option brace_terms behavior was the inverse
    of the documentation. As the docs describe what one would expect and
    is consistent with YAP, the implementation is fixed. We do not expect
    this option to be frequently used. Code using brace_terms(true) must
    be updated to use brace_terms(false). If you need to do a runtime
    check to beor conditional compilation compatible with older versions,
    one can use this condition to verify the correct new behavior.

    term_string({a}, S, [brace_terms(false)]), S == "{}(a)"
  • FIXED: Missing import into library(listing).

  • ADDED: write_term/2: option quote_non_ascii. This option is enabled
    by default for write_canonical/1.

  • ADDED: PL_write_term(): PL_WRT_QUOTE_NON_ASCII flag

  • FIXED: write_canonical/1 to use the brace_terms option as false.

  • FIXED: Make write/1 and friends escape characters that the stream
    cannot represent.

  • FIXED: write/1 and friends: we must check that the first character
    can be represented by the stream.

  • ADDED: Server socket support to SICStus 4 library(sockets) emulation.

  • FIXED: If we abort in the tracer from a redo port that is on a foreign
    predicate we must discard this (foreign) frame.

  • PORT: First attempt to support MacOs M1 with brew deps in /opt/homebrew

  • ENHANCED: Base clause indexing hash for indirect types (strings,
    bigints and rationals on the start, end and length if the size exceeds
    4 machine words. Without, the time to compute the hash easily becomes
    dominant. Found by Rick Workman.

  • REFACTOR: Get all index key computation in one place.

  • BUILD: Provide more control over the PGO build.

  • ADDED: argv_options/3 to process type number

  • FIXED: profile/1 involving code executed in a temporary module.

  • MODIFIED: This patch modifies PL_prof_type_t, the interface to
    extend the SWI-Prolog profiler. Foreign code using this may need to
    be updated. Most likely only used by xpce.

  • FIXED: dif/2: we should ignore unrelated attributes.

  • FIXED: Issue#907: failure to fully reclaim clause indexes under
    some loads.

  • CMAKE: Support older CMake versions.

Package bench

  • BUILD: Fixed running the benchmarks if GMP is not provided (
    causes an integer overflow).

  • ENHANCED: Allow deleting the files for certain benchmarks and
    automatically skip these.

Package clib

  • ENHANCED: Use mallinfo2() when available. By @mgodan1.

  • FIXED: #pragma inside an if () else goes wrong on gcc.

  • PORT: Silence deprecated vfork() message.

  • SANDBOX: Declare part of the SHA predicates sandbox safe.

Package http

  • ENHANCED: verify server address when starting an HTTP server and
    raise an error if this is invalid.

  • FIXED: Handle ansi(Style, Fmt, Args), url(Pos) and url(URL, Label)
    message line elements when formulating an HTTP response.

  • ADDED: Handle new console hyperlink message line items when converting
    error messages to plain text.

  • TEST: More debug messages for and avoid reporting
    expected errors.

  • FIXED: javascript quasi quotation for regex objects holding

  • TEST: Simplified shutdown management for the http:proxy tests.

Package jpl

  • CLEANUP: Type correctness in debug messages.

  • COMPAT: Allow qid_t to be an opaque pointer.

  • TEST: Disable prolog-in-java test if hamcrest-core is not found
    (broken on Macports)

Package mqi

  • FIXED: Fix bug in docs that used old (invalid) parameters to Python

  • FIXED: Updated Python library on to match this version
    swiplserver · PyPI

  • FIXED: Hang with multi-byte UTF8 characters reported by @Losbarthos
    Details in: Problem with unicode characters (e.g. →) in prolog file · Issue #14 · SWI-Prolog/packages-mqi · GitHub

    The MQI implementation had a bug where sends to MQI expected the
    message header to provide a count of Unicode code points instead of
    what it should have been: UTF8 bytes. This has been corrected but is a
    breaking change, so:

  • ADDED: A simple protocol versioning interface to the MQI. There is
    now a mqi_version/2 predicate and the MQI returns Major and Minor version
    in its response to an initial connect message.

  • ADDED: The swiplserver Python library properly detects the original
    and fixed versions and works against both of them.

  • TEST: Added tests for multi-byte UTF8 characters

  • TEST: Do not run tests if we do not have Python3.

  • ADDED: Created Python swiplserver 1.0.1 on
    (swiplserver · PyPI) to include fixed file
    handle leak

Package nlp

  • MODIFIED: Tokenize +digits as [+, int]. This is consistent with
    read/1 parsing +42 into +(42).

Package pengines

  • FIXED: Pengine emulation of tab/1 to accept an expression.

  • ADDED: Deal with new url message line element.

  • ADDED: handle full_stop(Bool) and nl(Bool) in translating Prolog
    terms to HTML.

Package plunit

  • FIXED: Allow include/1 to include tests between begin_tests/1 and
    end_tests/1. This patch is incomplete because failing tests are
    reported with the source line of he included file but the file name
    of the main file.

Package protobufs

  • BUILD: Silence message about enabling tests. We want the cmake run
    as quiet as possible.

Package readline

  • PORT: allow readline to be installed in /opt/homebrew/
  • PORT: (MacOS M1 with homebrew) allow readline to be installed in

Package semweb

  • FIXED: term_expansion/2 for rdf_meta/1 contained a !, preventing
    other rules to fire.

  • ADDED: rdf_meta/1: apply conversion in SSU heads.

  • FIXED: rdf_global_term/2: Allow for zero-arity compounds.

  • COMPAT: do not require white space after the subject and predicate
    of ntriple format.

Package sgml

  • ENHANCED: xsdp_subtype_of/2 to be fully logical. Wouter Beek.

Package ssl

  • PORT: error: ‘rsa’ undeclared for old OpenSSL and LibreSSL.

  • PORT: Make the package use the OpenSSL 3.0 API rather than
    the deprecated 1.1 API when compiled against OpenSSL 3. Patches
    Contributed by Matt Lilley.

  • PORT: Silence SecKeyChainOPen deprecation for MacOS.

  • PORT: Fix build on OpenBSD 7.0 using LibreSSL LibreSSL 3.4.0 made
    struct ssl_session_st opaque.

Package swipl-win

  • CLEANUP: Avoid messagebox when terminating.

  • PORT: Demand Qt 5.15 or 6.

  • FIXED: Simplied exit menu, working again, fixed QVariant type()
    usage warnings

Package xpce

  • FIXED: Issue#10 for swipl-win: display->confirm hides message
    box in the background.

  • FIXED: Issue#14 (swipl-win, should be xpce)
    emacs_frame->on_current_desktop failed if the frame is
    iconized. This keeps creating new frames rather than reusing them.

  • FIXED: frame->expose for Windows when xpce is running in the

  • CLEANUP: workaround to suppress a false positive warning from gcc-11
    and avoid a pragma at the same time

  • FIXED: Transfer selection from xpce as UTF-8 when requested using a
    media type (text/plain;charset=utf-8).

  • FIXED: Handle new message elements for generating feedback in PceEmacs.

  • FIXED: for MacOS

  • FIXED: GUI tracer: avoid instantiation error. Kwon-Young Choi.

  • FIXED: Allow the Prolog Navigator to work with zero-arity compounds.

  • ENHANCED: Avoid check/0 to report autoload/2 to be redefined.

  • ADDED:, replacing and client.c.