[ Modules | The ECLiPSe Built-In Predicates | Reference Manual | Alphabetic Index ]

lock(+Module, +Password)

Locks the access to the module Module, but allow unlocking with the password Password
Module
Atom.
Password
String.

Description

Used to forbid the access to the given module when not using its interface.

The module can later be unlocked by calling unlock(Module, Password).

An error is raised (error 82) when trying to re-lock a locked module. It must be unlocked first.

Modes and Determinism

Exceptions

(4) instantiation fault
Module or Password is/are not instantiated.
(5) type error
Module is instantiated, but not to an atom or Password is instantiated but not to a string.
(80) not a module
Module is not a module.
(82) trying to access a locked module
Trying to access a locked module Module.

Examples

Success:
     [eclipse]: [user].
      :- module(m).
      :- export p/0.
      p :- writeln(hello).
      user        compiled 60 bytes in 0.00 seconds
     yes.
     [eclipse]: lock(m, "pass").
     yes.
     [eclipse]: module(m).
     trying to access a locked module in module(m)
     [eclipse]: import p/0 from m.
     yes.
     [eclipse]: p.
     hello
     yes.
     [eclipse]: call(p) @ m.
     trying to access a locked module in p
     [eclipse]: unlock(m, "pass").
     yes.
     [eclipse]: call(p) @ m.
     hello
     yes.

Error:
     lock(M, "pass").                       (Error 4).
     lock(m, Pass).                         (Error 4).
     lock(1, "pass").                       (Error 5).
     lock(not_a_module, "pass").            (Error 80).
     lock(m, "pass"), call(p) @ m.          (Error 82).
     lock(m, "pass"), lock(m, "new_pass").  (Error 82).



See Also

lock / 1, unlock / 2, get_module_info / 3