Ann: SWI-Prolog 8.5.16

Dear SWI-Prolog user,

SWI-Prolog 8.5.16 is ready for download. It has been a long time, in
part due to holidays and in part due to the many changes that made it
hard to pick a good time for the release. Still, some work I rather had
seen in 8.5.16 is not there yet. Notably I would have liked to see the
work by @peter.ludemann on a new, more robust C++ interface that also
covers a large part of the C API in 8.5.16. Unfortunately that needed to
be posponed as we first need to fix some portability issues. Also the
WASM version is not there where I had wished it would be. The Prolog
WASM core is now fairly stable, but the JavaScript wrappers are not.
Both the interface will change and the interface needs better error
handling and testing. This is now targetted for 8.5.17.

Most work is on portability. Highlights:

  • Windows version: various UTF-16 encoding issues, resolved many
    file system interaction issues: long paths, UTF-16 names, issues
    with Windows the C runtime library resolved by using the Win32
    API directly for a larger part of the code.
  • WASM version: Core works fine. The meaningfull extensions are
    now included into the build. The applicable part of the test
    suite passes. JavaScript interface is still work in progress.
  • Lots of changes to the package dependencies and configuration
    to improve support on restricted builds (notably single threaded).
  • Fixes to engine and foreign yield.
  • Several issues raised by the Debian maintainer (Lev). Hope
    to get 8.6.x into the next Debian release cycle.
  • Fixed possible crash in crypto libraries by @matthijs

Due to the scope of the changes some regression is not unlikely. Please
test and report.

Enjoy --- Jan

P.s. MacOS binaries will be available later today or tomorrow.
Build machine is being updated …

SWI-Prolog Changelog since version 8.5.15

  • DOC: Fix typos, clarify return codes and error conditions for many
    foreign language interface functions (PL_*()).

  • FIXED: If creating an atom fails due to invalid representation of the
    source text (e.g., invalid UTF-8 sequence) we now raise an exception.

  • WASM: Using node we by default have no control over the terminal.
    Need to find out whether it is possible to make that work.

  • TEST: Lower test recursion on systems with limited C stack

  • WASM: Disabled IEEE754 tests as float rounding does not appear to be
    suported and many WASM float functions are imprecise.

  • WASM: Do not support open(pipe(Command), …) as popen() is a dummy.

  • FIXED: transaction/1 in single threaded version.

  • ENHANCED: Simplify clause visibility rules with transactions.

  • PORT: Windows: install a copy of libstdc++*.dll while building and
    add this to the installer if INSTALL_TESTS is active.

  • PORT: Be more conservative with C stacks on WASM. Fixes dealing with
    cyclic terms in assert/1 and friends.

  • BUILD: make_library_index/1 to silently ignore errors from
    use_foreign_library/1. This works around a dependency issue for
    building the INDEX.pl files during build. This is not ideal as in
    theory we could do exports conditionally based on what is in the
    foreign object. At this moment this does not happen.

  • MODIFIED: qsave_program/2 and compilation using -c to interpret the
    --emulator=file`` flag (or emulator(Emulator) option) independently from the –stand-alone`` option. This allows creating non-stand-alone
    executables that use a specific emulator path.

  • TEST: When using -DINSTALL_TESTS, install foreign plugins that
    only support testing.

  • DOC: Describe the design of the Windows file system interaction and
    its limitations.

  • ENHANCED: Test Windows file identify using the device identifier to
    deal with links.

  • TEST: Added more file name tests.

  • FIXED: Windows: turned ‘$mark_executable’/1 into a dummy as it does
    nothing meaningful anyway.

  • FIXED: Windows opendir(), etc. emulation. Use more efficient file
    finding and avoid a possible inifinite loop.

  • ENHANCED: expand_file_name/2: provide signal handling while expanding
    such that we can interrupt.

  • FIXED: Windows working directory to use SetCurrentDirectoryW() for
    supporting longer path names.

  • FIXED: Sprintf() for wide character strings with surrogate pairs.

  • FIXED: Sprintf() for NULL char * that have non-ASCII encoding.

  • FIXED: Windows implementation of size_file/2 to use
    GetFileAttributesExW() because _wstati64() cannot handle long file
    names.

  • ENHANCED: Windows: Use more robust translation to Windows path
    names. Support long file names using the "\\?\" or "\\?UNC\"
    prefix.

  • FIXED: Windows dlopen() emulation path handling.

  • ENHANCED: fallback to the default mem functions in the GMP hooks…
    …when invoked out of the context of Prolog.

    See
    Sweep: SWI-Prolog Embedded in Emacs
    for relevant discussion.

  • FIXED: Windows conversion to UTF-16 file names to introduce surrogate
    pairs when needed.

  • MODIFIED: expand_file_name/2 return entries in simple lexical order
    rather than using mbscoll(). The latter did not work anyway because
    the pattern and file names use UTF-8 rather than native multibyte.

  • FIXED: existence checking on Windows for expand_file_name/2

  • FIXED: Windows: do not canonicalize characters of file names > 0xffff
    using towlower() as this function truncates to 16 bits. Assumes there
    are no letters with case above 0xffff.

  • FIXED: Windows: translation of wchar_t to UTF-8 for surrogate
    pairs. Fixes e.g. ?- string_bytes('\U0001f600\U0001f604', L, utf8).

  • FIXED: Windows: ensure surrogate pairs to the console streams are in
    the same WriteConsoleW() call. This fixes writing Unicode code points >
    0xffff to user_error. The patch also writes output to user_error
    in larger chunks. Note that the default Windows console does not handle
    surrogate pairs. The Windows Terminal does.

  • DOC: Describe poor exceptions from failing file system operations.

  • FIXED: Actually use overruled PATH_MAX in uxnt.c emulation.

  • DOC: rename_file/2: updated docs.

  • ADDED: Prolog flag path_max to get access to the manimum file name
    length on the OS.

  • FIXED: string_bytes/2 in mode (+,-) for UTF-16 encoding on
    Windows. Reported by Matthias Gondan.

  • PORT: Emscripten updates: Move required settings to Emscripten.cmake
    and add support for GMP

  • DOC: Make compile if library(shlib) is not present

  • FIXED: Issue#1025: stream encoding wchar_t not returned as stream
    property

  • FIXED: Issue#1021: engine_next/2 for a next answer when the previous
    return was due to a yield crashes.

  • FIXED: WASM Issue#1023: sleep/1 no longer worked.

  • BUILD: Dependency issue for building the library indexes. After
    comments and a hint by Matthias Gondan.

  • TEST: Avoid more tests that depend on threads in single threaded
    version.

  • WASM: library(readutil): use shared use_foreign_library/1.

  • WASM: Include http into wasm version

  • WASM: Activate STATIC_EXTENSIONS and include (part of) the clib
    package.

  • BUILD: Build option cmake -DSTATIC_EXTENSIONS which adds selected
    extensions (packages) to libswipl. In this scenario dynamic linking
    is disabled and use_foreign_library/1 is adjusted to call the already
    existing install function of the extension.

  • WASM: Added calling JavaScript from Prolog, exchange DOM elements
    and adding scripts from Prolog.

  • WASM: Renamed js_call/1 to js_run_script/1 for consistency

  • WASM: Avoid the need for a frame in Prolog.query(String).

  • WASM: Provide Prolog.message_to_string()

  • WASM: Allow a frame to discard all data

  • WASM: Many changes to calling Prolog from JavaScript. These patches
    work to more high level interaction with Prolog from JavaScript.
    This work should be considered experimental.

  • WASM: Perform UTF-8 decoding on output such that we can write Unicode.

  • WASM: Handle sleep/1 using JavaScript setTimeout()

  • WASM: Allow _ in file names.

  • WASM: Reduce auto-yield frequency and avoid the event loop when < 20ms.

  • WASM: Focus on input next/stop when requested.

  • WASM: Set default package list to plunit, chr and clpqr

  • WASM: Extended shell.html demo. Working asynchronous behavior, command
    line history and persistent files in localStorage and manage files.

  • WASM: Many extensions to calling Prolog from JavaScript. Added support
    for (auto) yielding to achieve asynchronous behaviour in the browser.

  • ADDED: heartbeat mechanism: by setting the Prolog flag heartbeat, the
    multifile predicate prolog:heartbeat/0 is called every N inferences.

  • FIXED: PL_yield_address() (foreign yielding) effectively popped one
    level of the foreign frame stack.

  • WASM: Updated instructions in CMAKE.md. “Native friend” is no
    longer needed.

  • WASM: Pass -s ALLOW_MEMORY_GROWTH=1 to allow for bigger stacks.

  • WASM: libswipl should not be a dynamic library on emscripten

  • WASM: Attempt to support threads. Compiles, but doesn’t work on
    either Firefox or node.

  • WASM: Addes js_call/1 to call JavaScript

  • WIP: trying to deal with reading.

  • WASM: added ttymode() to Prolog JavaScript API.

  • WASM: Minimal running example.

  • CLEANUP: Type safety of property enumerators

  • CLEANUP: get rid of function pointers without declared arguments.

  • WASM: Make init argv default

  • WASM: Put file system as /swipl and make this the Prolog home.

  • WASM: Avoid absolute path messages when linking swipl-web

  • FIXED: autoloading: read the module header using operators from the
    system module to avoid user operator declarations to cause a failure
    reading this.

  • ENHANCED: Performance tuneup - reduce number of arithmetic operations
    for pivot - replace one call to lists:member/2 with memberchk/2

  • ENHANCED: Optimize nth1/3 using ‘$seek_list’/4

  • DOC: Add => to the operator table.

Package RDF

  • PORT: Make library(rdf_write) work without the RDF db.

Package bdb

  • PORT: Support static linking

Package chr

  • WASM: Install generated files in wasm-preload

Package clib

  • TEST: Synchronize libraries included and tests included. Also includes
    library(filesex) into the Emscripten version.

  • PORT: Windows executable files may not have read access if they are
    a reparse point.

  • FIXED: relative_file_name(Dir, SameDir, Rel) to return Rel as .
    rather than ''.

  • TEST: Disable tests that need threads on the single threaded version.

  • WASM: Re-group plugins to make it easier to select only those that
    do not depend on OS features.

  • PORT: Replace old K&R declarations

Package http

  • TEST: Synchronize installed and tested packages.

  • DOC: http_open/3: missing docs due to empty line.

  • WASM: Provide a stripped down version for the WASM target, currently
    providing the library(http/html_write), the json and stream library.

  • ADDED: Mime type mappsing from .data to
    application/octet-stream.

  • ADDED: MIME type rules: added .wasm → application/wasm.

Package ltx2htm

  • PORT: Allow for static linking

Package mqi

  • DOC: hard links to swipl manual

  • DOC: hard links to swipl manual the “section references” do not get
    connected properly

  • FIXED: Residual constraints on variables are now returned in a special
    binding variable called ‘$residuals’ MQI Prolog change only, no
    changes to the language clients (e.g. the swiplserver Python library)
    are required.

    Usage:

    with server.create_thread() as client:

result = client.query("member(X, [A, B, C]),
put_attr(X, my_module, x).")
[{'$residuals': [{'args': ['A', 'my_module', 'x'],
'functor': 'put_attr'}], 'X': 'A', 'A': 'A', 'B':
'_', 'C': '_'},
{'$residuals': [{'args': ['B', 'my_module', 'x'],
'functor': 'put_attr'}], 'X': 'B', 'A': '_', 'B':
'B', 'C': '_'},
{'$residuals': [{'args': ['C', 'my_module', 'x'],
'functor': 'put_attr'}], 'X': 'C', 'A': '_', 'B':
'_', 'C': 'C'}] == result
  • FIXED: If exceptions happen during serialization to JSON, MQI will
    now send an exception message instead of hanging

Package semweb

  • TEST: Make tests work in restricted single threaded version.

  • BUILD: add cmake dependency

  • PORT: Make the turtle and ntriples readers and writers load without
    library(semweb/rdf_db). Still issues using them.

  • PORT: Do build build library(semweb/rdf_db) in single threaded
    mode. In this mode the semweb only provides the turtle and ntriple
    readers and writers.

Package sgml

  • CLEANUP: Avoid function pointers with incomplete prototypes and make
    the install function follow the conventions to allow for statically
    linked extensions.

Package ssl

  • FIXED: Zero the PL_CRYPTO_HASH_CONTEXT struct on first allocation

Package xpce

  • TEST: Create files and directories in temp.

  • PORT: Avoid using Windows stat()

Package zlib

  • TEST: Disable socket based tests if sockets are not supported.
4 Likes

Did you want to include #wasm_demo in the announcement?

Not necessarily. It’s been advertised enough.