[ Modules | Reference Manual | Alphabetic Index ]

# unlock(+Module, +Password)

Unlocks the access to the module Module, if the password given in Password is correct

Module
  Atom.
Password
  String.

## Description

unlock(Module, Password) unlock a module previously locked with lock_pass(Password). The access to the module is now again possible.

An error is raised (and the module not unlocked) when trying to unlock a module with a wrong password or when trying to unlock a module locked with lock/0.

### Modes and Determinism

- unlock(+, +) is det

### 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
(98) key not correct
  Key not correct

## Examples

        % After compiling the following code:
         :- module(m).
         :- export pub/0.
         pub :- writeln(pub).
         priv :- writeln(priv).
         :- lock_pass("secret").

        ?- 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)

        ?- unlock(m, "pass").
        key not correct in unlock(m, "pass")

        ?- unlock(m, "secret").
        yes.

        ?- call(priv) @ m.
        priv
        yes.

        ?- assert(foo) @ m.
        yes.

## See Also

lock / 0, lock_pass / 1, get_module_info / 3