Ann: SWI-Prolog 9.1.11

Dear SWI-Prolog user,

SWI-Prolog 9.1.11 is ready for download. Most of the fixes deal
with relateively minor issues. There are two noteworthy new
libraries:

  • library(macros) provides simple macro expansion, primarily
    intended to deal with e.g., compile time constants and
    simplify writing larger terms.
  • library(rwlocks) add high-level read/write locks to the
    synchronization primitives.

As a sign of still ongoing cooperation between Prolog implementations,
there is now evaluable_property/2 (currently as library predicate), which generalizes current_arithmetic_function/1 (which should have been named
current_evaluable/1).

Enjoy --- Jan

P.s. We reached 800 stars on GitHub - SWI-Prolog/swipl-devel: SWI-Prolog Main development repository
Please help to get to 1,000!

SWI-Prolog Changelog since version 9.1.10

  • ADDED: evaluable_property/2 Proposal to inspect evaluable functions.

  • ADDED: indicate DCG rules in xref_defined/3 This makes
    xref_defined(Src, Head, How) succeed (also) with How = dcg for DCG
    grammar rules.

  • MAINTAIN: Add CI based on Github workflows

  • ADDED: library(rwlocks), implementing read/write locks.

  • FIXED: Avoid closing a stream with an alias If a stream-handle is
    created for a stream with an alias (e.g., by stream_property/2),
    the stream would be closed if this handle is garbage collected.

  • ENHANCED: library(macros) to leave #Var alone.

  • ADDED: library(prolog_colour): Add support for library(macro).

  • ADDED: library(macros) A general purpose compile time macro expansion
    mechanism based on term_expansion/2.

  • MODIFIED: Removed undocumented prolog:rename_predicate/2 hook.
    This hook was used to be able to wrap predicates. That is currently
    achieved more reliable and dynamically using wrap_predicate/4.

  • FIXED: Ensure expand_term/2 cannot alter the current source location.

  • FIXED: #1174: read_pending_codes/3: release stream on EOF or error.

  • DOC: details about building packages

Package clib

  • FIXED: uuid/1,2: Prolog implementation for random UUID This
    implementation is only used if the C based ossp-uuid implementation
    cannot be found.

    Set the two most significant bits (bits 6 and 7) of the
    clock_seq_hi_and_reserved to zero and one, respectively according to
    RFC 4122 - A Universally Unique IDentifier (UUID) URN Namespace

Package http

  • DOC: http_reply_from_files/3: document need for trailing /

  • ADDED: Full HTTP chunked support for CGI streams The CGI stream,
    as used by the HTTP server framework, supports setting the transfer
    encoding to chunked, but ctually had its own separate implementation.
    This commit shares most of the code with http_chunked.c and provides
    support for emitting chunk extensions as well as trailers.

  • ENHANCED: http_open/3: add lazy loading of chunked encoding support.

  • ADDED: http_is_chunked/1, http_chunked_add_trailer/3 and
    http_chunked_flush/2. These predicates support HTTP chunked out of
    band data. Unfortunately neither chunk extensions, nor trailer lines
    are widely accepted by clients.

  • ADDED: UTF-8 as default encoding for several SPARQL related content
    types.

Package redis

  • FIXED: Better reconnect implementation
4 Likes

Thank you!
(If I said thank you for every release, it still wouldn’t be enough thanks. )

Are there explicit open details and discussions about “ongoing cooperation between Prolog implementations”? Or is this a sort of thing that just happens organically, according to each implementor and their observations of other implementations?

In this case it was initiated by Paulo Moura as Logtalk developer. There are occasional discussions between developers to sync specs. By far not enough though :frowning:

1 Like

Some complaints on an Apple M1 system with clang15:

-- Looking for term.h - not found
-- Looking for ncurses/term.h - not found
-- Looking for tgetent
-- Looking for tgetent - found

Later, we have:

pl-term.c:153:13: error: call to undeclared function 'tgetent'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    switch( tgetent(buf_area, term) )

To me, it appears as if tgetent is found somewhere but neither in term.h nor in ncurses/term.h (the two places considered by pl-term.c).

The problem might be “fixed” by changing check_function_exists to check_symbol_exists in cmake/Config.cmake

# terminal
# check_function_exists(tgetent HAVE_TGETENT) # old
check_symbol_exists(tgetent term.h HAVE_TGETENT) # new

EDIT: fixed in quotes because terminal support would be disabled on that system until it is found elsewhere.

Thanks. My Mac says it is up-to-date and Xcode gives clang-14. How come you get clang-15?

Now, before taking actions, I’d like to know what happened to term.h. Apparently the function is still in libc. Is something broken with the SDK installation on your system or has Apple decided to discontinue tgetent() and friends and do they that by stopping the distribution of term.h while keeping the function for backward binary compatibility.

The status of tgetent() is a bit unclear. In my mac it still has a manual page and although they say it is poorly standardized and my be discontinued, it doesn’t suggest that plan is very concrete. Besides, compiler versions and SDK are different things.

clang15 is used on one of the machines for testing R-packages. That’s all I know. You can see the error log here,

https://cran.r-project.org/web/checks/check_results_rswipl.html

(the red links M1mac). I am sorry for not being able to provide more detail.

For what it’s worth, tgetent docs require both ncurses.h and term.h to be included,

I pushed a fix checking for term.h. Also reorganized pl-term.c a little such that we keep tty_size/2 if possible as that depends on ioctl()

The code already includes both if they can be found.

Thanks, Jan.

My point was that both ncurses.h and term.h need to included (not one or the other or both). Let’s see if the problem has been solved using your patch. It may take some time since I cannot access CRAN’s testing machines.

This type of portability always requires little balancing. Using the OS+Version is hard as you never know when it changes and you have to make rules for all supported systems. Doing it dynamically based on feature tests is much better, but one has to find the right rules. You’d assume that if tgetent() exists in libc, the system will also have the required headers.

Alas, that seems not the case, so now we check for the existence of term.h and we also load ncurses.h if it exists. Of course there could be installations where you need both but only term.h is provided. Let us hope that is not the case … There could also be systems where tgetent() exists but is incompatible or does something very different. Incrementally you try to find minimal rules that support all target systems.

Luckily this has become simpler over time with fewer and better standard compliant POSIX like systems. Apple is a common outlier :frowning:

Hope it is ok if I suggest another little improvement, regarding the test system. As it is now, I think, it tests the entire system with all extra packages (say, xpce), even if these packages have deliberately chosen not to be included in an installation. Is this correct?

The thing is that the tests of the missing packages raise errors in test_installation. I am wondering if the tests for the non-existent packages could be skipped.

No. But, testing the archive package tested the archive library using a file installed by the xpce package. I pushed a fix that avoids this. Also pushed a fix installing the pcre test data and deal with the new Python tests.

There is still some unknown problem with the QLF Unicode tests for running the installed tests. I’ll try to have a look at that later.

edit that issue is fixed now. test_installation/0 (when the tests are installed as part of the distribution) now passes if some packages are missing. Tested without xpce and JPL.

Thanks, got it. There’s one dependency missing, package cpp seems to require pcre, but I am a bit unsure if I can just add set(SWIPL_PKG_DEPS_cpp pcre) to cmake/PackageSelection.cmake. Because of the comment, “Package dependencies as computed using script/xref_packages.pl” in that file.

I think the real fix is to remove the use of pcre in the unit tests for the cpp package. We should avoid dependencies between packages when reasonable. Here, good old DCGs should do :slight_smile: @peter.ludemann ?

Just to avoid double work I replaced the re_match/2 and re_matchsub/3 calls with a little DCG magic.

I was being lazy. Thank-you.
(And the DCG is a lot easier to read than the regex – probably faster also)