Library(persistency) data files must have a blank last line

library(persistency) creates *.pl files (I call them journals) for persisting predicates.

When a journal file is opened it is opened with append. When a predicate is asserted to the journal it is appended to the end of the file. If the last line is NOT a blank line then the next predicate appended will be on the same line as the last line ( possibly with a predicate) and thus appear as a term with a period in the middle, e.g.

assert(foo(a,1)).assert(foo(b,2)).

instead of

assert(foo(a,1)).
assert(foo(b,2)).

This error does not occur with a correct usage of library(persistency). The error occurred because I hand deleted the empty line when reviewing the file in a text editor.


The error generated for such a mistake will be like

ERROR:    Unknown message: illegal_term(assert(foo(a,1)).assert(foo(b,2)))

Or as ChatGPT would say

This error is related to the Prolog programming language and the use of the persistency library. The persistency library creates journal files with the extension .pl for persistent predicates. The journal files are opened in append mode and each predicate assertion is added to the end of the file. However, if the last line in the file is not a blank line, then the next predicate assertion will be on the same line as the last line, causing the predicates to appear as a single term with a period in the middle. This can lead to an error, as the Prolog interpreter will not recognize the combined term as a legal term. The error message states “Unknown message: illegal_term(assert(foo(a,1)).assert(foo(b,2)))” which indicates that the Prolog interpreter has encountered an illegal term that it cannot recognize.

or using regenerate response

The error message is indicating that the line being asserted to the journal file is an illegal term. This is because the term is in the form of “assert(foo(a,1)).assert(foo(b,2))”, which is not a valid Prolog term as there should be a new line separating each assertion. The library(persistency) is designed to handle this, but in this case, the empty line separating the terms was deleted, leading to the error. To resolve the issue, add a new line after each assertion in the journal file.