This primitive is usually used a directive in the source code of the module to be locked.
A module locked with lock/0 cannot be unlocked. Repeated locking (from within the module) is silently accepted.
% After compiling the following code:
:- module(m).
:- export pub/0.
pub :- writeln(pub).
priv :- writeln(priv).
:- lock.
?- module(m).
trying to access a locked module in module(m)
?- call(pub) @ m.
pub
yes.
?- call(priv) @ m.
trying to access a locked module in priv
?- assert(foo) @ m.
trying to access a locked module in assert_(foo, m)