Records in Old Prolog

Kenichi Sasagawa
2 min readSep 23, 2024

--

Deprecated Predicates

In old Edinburgh Prolog, there was a feature called record. It was used to register data in an internal database. In modern Prolog, these have been deprecated and replaced by assert and retract. This was a dedicated database for data, and it did not affect the program itself. There may still be use cases for it in certain situations.

Test Code

Records are connected in a bidirectional chain. Data can be retrieved from a reference number using instance/2. A hash table is also provided, allowing for fast access with specific keys. Next is the test code to verify correct functionality.

test1 :-
recordz(client, client(jones, life, 00245), Refnum),
recordh(alphabet, jones, Refnum),
recordh(insurance, life, Refnum).

test2 :-
retrieveh(alphabet, jones, Refnum),
instance(Refnum, X),
write(X).

test3 :-
eraseall(foo),
recordz(foo, foo(a, 1), _),
recordz(foo, foo(b, 2), _),
recorda(foo, foo(c, 3), _),
recorda(foo, foo(d, 4), _),
recordz(foo, foo(e, 5), _).
test4 :-
key(foo, Ref),
nref(Ref, Ref1),
nref(Ref1, Ref2),
nref(Ref2, Ref3),
nref(Ref3, Ref4),
not nref(Ref4, Ref5),
pref(Ref4, Ref3),
pref(Ref3, Ref2),
pref(Ref2, Ref1),
pref(Ref1, Ref).
N-Prolog Ver 3.25
?- ['tests/record.pl'].
yes
?- test1.
yes
?- test2.
client(jones,life,245)yes
?- test3.
yes
?- test4.
yes
?-

Simple Questions

While testing, I began to wonder: Old Prolog may have separated data and program. Using assert allows the program itself to be modified, which is quite fascinating. However, when treating something as mere data, separating it from the program might have made things clearer. What led to the current situation? Nowadays, such record predicates seem to have been consolidated into assert and retract.

What were they aiming to do with this back in the days of DEC10 Prolog? I enjoy testing while imagining various possibilities. If Mr. Warren is reading this, I would be grateful for any insights you could provide.

sasagawa888/nprolog: interpreter and compiler to be compatible with ARITY/PROLOG(MS-DOS) (github.com)

--

--