Ann: SWI-Prolog 9.1.14

Dear SWI-Prolog user,

I have uploaded SWI-Prolog 9.1.14. This release updates the C++
and Python interfaces improves embedding on ELF based systems
and fixes some minor issues. Highlights

  • Janus (the Python interface) has received several incompatible
    changes that resulted from synchornizing the API with XSB. The
    main reason for this fast re-release is to reduce confusion
    due to outdated documentation on the website as well as to
    reduce get the (almost) stable API out as quickly as possible.

    This version also fixes a various issues wrt. Python reference
    counting and exception handling.

    Janus is now also included in the MacOS binary, linking against
    Python 3.11 when installed from the Python download site.

  • @peter.ludemann pushed various updated to the C++ interface.
    SWI-cpp2 is getting pretty stable.

  • Recent patches caused tty_size/2 to be unavailable in several
    versions.

  • The bundled packages did not hide internal symbols on ELF
    systems, making them vulnerable to name conflicts if
    SWI-Prolog is embedded. This work also supports all
    glibc flags for dlopen(), providing more control over
    shared objects (be it largely non-portable). This showed
    up with the sweep interface for GNU-Emacs. Thanks to
    @oskardrums for analyzing and testing.

  • Updated sweep to the latest version.

    Enjoy — Jan

SWI-Prolog Changelog since version 9.1.13

  • PORT: Further refine terminal support detection. Recent regression
    cause tty_size/2 to be undefined on systems where it can be supported.

  • ENHANCED: Compile all plugins using -fvisibility=hidden

  • ENHANCED: Use visibility attribute for install_t This allows
    compiling plugins with gcc -fvisibility=hidden, reducing the risc
    for symbol conflicts and reducing load time.

  • ADDED: open_shared_object/3: support all glibc RTLD_* options.

  • DOC: Clarify some details of blob and I/O functions

  • PPA: Dropped kinetic, added lunar

Package clib

  • FIXED: Export install function from hashstream.so

Package cpp

  • CLEANUP: Simplify blob interface and more Simplify blob interface
    (PlBlob) - Add PlTerm::unify_blob for unique_ptr - Add try/catch
    to blob callbacks - Improve documentation of PlBlob Rename some
    implementation functions to more meaninful names Fix inverted condition
    test (zero vs non-zero return code) Move some code from SWI-cpp2.h
    to SWI-cpp2.cpp Add PREDICATE_CATCH macro to remove copy&paste code
    duplication Rename some example classes to improve the documentation
    Improve some garbage collection tests for blobs Update with changes
    from swipl v9.1.12

Package ltx2htm

  • ENHANCED: Use more Unicode characters for math commands.

Package sgml

  • FIXED: Race condition in dtd_property/2 Can lead to Domain error:
    dtd_property’ expected, found entities(_37838)’

Package sweep

  • PORT: Explicitly export the symbols we need By default, plugins are
    now compiled with hidden visibility for internal symbols.

  • MODIFIED: Replace “faces styles” with a theme emulating PceEmacs
    This adds a custom theme called ‘sweeprolog-pce’ that mimics the
    highlighting of SWI-Prolog’s built-in editor, PceEmacs. It obsoletes
    the “faces styles” feature that Sweep provided thus far. For backward
    compatibility, The user option ‘sweeprolog-faces-style’ is retained
    and mostly still respected.

    Thanks to Stefan Monnier for suggesting this approach for simplifying
    Sweep’s code and making it more conformant with Emacs conventions.

    • sweeprolog-pce-theme.el: New file.

    • sweeprolog.el: Remove ‘sweeprolog-defface’ macro its
      ‘sweeprolog-*-face’ functions, use plain face definitions and refer to
      them directly by their names instead. Also extend
      ‘custom-theme-load-path’ to include the new sweeprolog-pce-theme.el.

    • README.org (Semantic Highlighting): Replace “Available Styles”
      subsection with new subsection “PceEmacs Theme”.

  • DOC: Extend the “Overview” manual section * README.org (Main Features)
    (Comparison with Emacs’s built-in Prolog mode): New subsections.

  • ADDED: Persistent history for Sweep top-levels This adds a new user
    option that controls the value of ‘comint-input-ring-file-name’
    in Sweep top-level buffers.

    • sweeprolog.el (sweeprolog-top-level-persistent-history): New user
      option.
      (sweeprolog-top-level-sentinel)
      (sweeprolog-top-level-setup-history): New functions.
      (sweeprolog-top-level-setup-buffer): Call
      ‘sweeprolog-top-level-setup-history’ when creating a new top-level
      buffer.
  • FIXED: Correctly recognize DCG grammar rules in ‘C-c C-d’ *
    sweeprolog.el (sweeprolog-beginning-of-predicate-at-point):
    Also return the module and neck operator of the predicate
    at point. (sweeprolog-insert-predicate-documentation)
    (sweeprolog-read-predicate-documentation-function)
    (sweeprolog-read-predicate-documentation-with-holes)
    (sweeprolog-read-predicate-documentation-default-function)
    (sweeprolog-read-predicate-documentation)
    (sweeprolog-document-predicate-at-point): Adapt to support DCGs and
    non-local predicates.

  • ENHANCED: Guess argument names for DCG grammar rules * sweeprolog.el
    (sweeprolog-predicate-completion-at-point) (sweeprolog-insert-clause):
    Support guessing argument names from documentation also for DCG
    grammar rules.

  • ENHANCED: Also highlight “undefined” head terms

  • ENHANCED: ‘sweeprolog-find-predicate/module’ improvements Allow
    finding modules and predicates in another window with prefix argument.
    Also improve prompt for ‘sweeprolog-find-predicate’.

    • sweeprolog.el (sweeprolog-read-predicate-prompt): Remove trailing
      colon and space.
      (sweeprolog-predicate-visible-p-function): New user option.
      (sweeprolog-read-predicate): Use it, and format PROMPT with predicate
      at point as the default argument.
      (sweeprolog-find-module)
      (sweeprolog-find-predicate): Add optional argument OTHER-WINDOW.
      (sweeprolog-describe-predicate): Adapt PROMPT argument passed to
      ‘sweeprolog-read-predicate’.

    • README.org (Finding Prolog Code): Expand.

  • ENHANCED: Improve DCG support Take into account DCG grammar
    rules and ensure they’re supported all around. Crucially, allow
    ‘sweeprolog-describe-predicate’ to display documentation for DCG
    grammar rules.

  • FIXED: Don’t change hooks globally * sweeprolog.el (sweeprolog-mode):
    Extend ‘kill-buffer-hook’ and ‘context-menu-functions’ locally rather
    than global.

  • ENHANCED: Add tooltip info for string-stye DCG terminals

  • ENHANCED: Export DCG non-terminals as ‘foo//N’, not ‘foo/N+2’ *
    sweep.pl (strip_det/2): Handle DCG non-terminals with determinism
    specification. (sweep_local_predicate_export_comment/2,
    sweep_exportable_predicates/2) * sweeprolog.el
    (sweeprolog-local-export-comment) (sweeprolog-local-export-comment):
    Adapt for DCG non-terminals.

  • ENHANCED: Highlight string-style DCG terminals

  • ADDED: highlighting and tooltip info for declaration options * sweep.pl
    (sweep_color_normalized_/4): Handle ‘decl_option/1’ fragments.

    • sweeprolog.el (sweeprolog-declaration-option): New face, used in…
      (sweeprolog-analyze-fragment-to-faces): …for ‘decl_option’ frags.
      (sweeprolog–help-echo-for-declaration-option): New function.
      (sweeprolog-analyze-fragment-help-echo): Use it.
  • ADDED: command for inserting example usage comments *
    sweeprolog.el (sweeprolog-top-level-example-mode): New minor
    mode. (sweeprolog-make-example-usage-comment): New command.
    (sweeprolog-mode-map): Bind it.

    • README.org (Example Usage Comments): New section.
  • ADDED: New command for expanding macros *
    sweep.pl (sweep_expand_macro/2): New predicate. *
    sweeprolog.el (sweeprolog-expand-macro-at-pos):
    New function. (sweeprolog-expand-macro-at-point):
    New command. (sweeprolog-context-menu-functions): Add…
    (sweeprolog-context-menu-for-macro): New function. * README.org
    (Macro Expansion): New section.

  • ADDED: Highlighting and tooltip info for macros * sweep.pl
    (sweep_color_normalized_/4): Handle ‘macro(String)’
    terms. * sweeprolog.el (sweeprolog-macro):
    New face. (sweeprolog-analyze-fragment-to-faces)
    (sweeprolog-analyze-fragment-help-echo): Handle ‘macro’ fragments.

  • FIXED: tokenizing adjacent operators Make Sweep’s Prolog tokenization
    functions more careful in their handling of unrelated adjacent
    operators. This fixes an issue that affects term-based movement
    commands and other commands that rely on ‘sweeprolog–forward-sexp’
    and friends.

    • sweeprolog.el (sweeprolog-next-token-boundaries)
      (sweeprolog-last-token-boundaries): Fix handling of
      adjacent (distinct) operators.

    • sweeprolog-tests.el
      (forward-sexp-with-adjacent-operators): New test case.

  • MODIFIED: Remove ‘-face’ suffix from face names Remove the ‘-face’
    suffix from the names of all defined faces as prescribed in (info
    “(elisp)Defining Faces”).

  • ENHANCED: faster completion-at-point for predicates Filter
    predicate completion candidates according to the text near
    point before formatting and computing argument names. This makes
    completion-at-point for predicates much faster when there are lots
    of known predicates.

    • sweeprolog.el (sweeprolog-predicate-completion-at-point): Pass
      (partial) functor at point to…
    • sweep.pl (sweep_predicate_completion_candidates/2): Filter
      predicates based on new Sub argument.

Package swipy

  • FIXED: janus.Query(): properly handle exceptions.

  • ADDED: Allow compiling a Python string and compile into a module.

  • MODIFIED: Renamed installed module to janus_swi

  • COMPAT: added is_py_object/1, renamed add_py_libdir/1,2 to
    py_add_libdir/1,2

  • FIXED: Several issues wrt Python reference counts.

  • COMPAT: Use @true, @false and @none for the Python constants.

  • COMPAT: Functor for PyTuples in Prolog changed to -/N Decided in Zoom
    call August 11.

  • FIXED: Wrong return code (ignoring error)

  • FIXED: Memory leak in py_iter/2,3

  • MAINTENANCE: Use debug version of Python when enabling asan.

  • FIXED: PyEval_GetBuiltins() returns a borrowed reference Decrementing
    destroys the builtins …

  • FIXED: We should not Py_DECREF the output of PyErr_Fetch()

  • FIXED: the output of PyUnicode_AsUTF8AndSize() disappears with the
    object __name__ seems to generate a new PyObject and thus we must
    use the UTF-8 string before decrementing the reference count for the
    PyObject *name.

  • PORT: CMake option() is only boolean.

  • PORT: Allow asking for a Python version Use cmake
    -DCPYTHON_VERSION=3.11 or -DCPYTHON_VERSION=3.11;EXACT.

  • TEST: Port XSB Janus tests

  • TEST: Imported tests from XSB

  • ENHANCED: Connect Python console I/O to Prolog’s when rebound.

  • FIXED: Return empty tuple as :().

  • ENHANCED: Various fixes, allow passing arbitrary Prolog terms,
    docs This is a elaborative commit that introduces janus.Term to
    represent arbitrary Prolog terms, represents Prolog exceptions using
    janus.PrologError which uses janus.Term for storing the exception term.

    It also cleans up the documentation and fixes several issues.

  • ENHANCED: Error handling for calls from Python to Prolog. Introduce a
    class janus.PrologError to represent the errors. This patch also
    changes the representation and printing of Python errors.

  • PORT: py_run(“from janus import *”) requires Python >= 3.10 This
    patch ensure the shell is still started and prints a message.

  • TEST: Avoid running tests using := in < 3.8 versions of Python.

Package xpce

  • ENHANCED: Hide internal xpce symbols This avoids symbol conflicts
    and reduces the startup time

Hi Jan, I met difficulties to compile this version and the cause is cmake. I had to install it manually, but fnallly it did not work correctly:

make[2]: *** Aucune règle pour fabriquer la cible « home/library/__INDEX.pl », nécessaire pour « src/CMakeFiles/library_index_library_always ». Arrêt.
make[1]: *** [CMakeFiles/Makefile2:1908 : src/CMakeFiles/library_index_library_always.dir/all] Erreur 2
make: *** [Makefile:166 : all] Erreur 2

I believe that the best for Debian 12 would be to work with cmake Debian package, but the previous manual installation produced also a cache error. I am lost…

Thanks for reporting.

Ah, commit bb091d081615c3fecb10f132db457d10887e1390 was added to work around warnings using Microsoft Visual C++ projects. It works fine, but only using Ninja or MSVC. So, either use -G Ninja to Cmake or revert the above commit.

I’ll see whether I can find an elegant work around.

edit Pushed 0ec564164a6af1d045f30a46d6931eebcf523015 to address this.

Hello Jan,

I’ll see whether I can find an elegant work around.

I presume that’s what you did, because it works now:

joseph@mx:/usr/local/swipl-devel$ swipl --version
SWI-Prolog version 9.1.14 for x86_64-linux

Again, many thanks for SWI-Prolog ! :+1: