It is impossible to unlock a module locked with lock/1. However, a module locked using lock/2, can still be unlocked with unlock/2.
An error is raised (error 82) when trying to lock a locked module.
Success: [eclipse]: [user]. :- module(m). :- export p/0. p :- writeln(hello). user compiled 60 bytes in 0.00 seconds yes. [eclipse]: lock(m). yes. [eclipse]: module(m). trying to access a locked module in module(m) [eclipse]: import p/0 from m. yes. [eclipse]: call(p) @ m. trying to access a locked module in p [eclipse]: p. hello yes. Error: lock(M). (Error 4). lock(1). (Error 5). lock(not_a_module). (Error 80). lock(m), call(p) @ m. (Error 82).