Qualified Names

For qualified names a notation based on the colon (:) operator can be used when invoking predicates or evaluable functions. The module name itself can be structured by means of the slash (/)/2 operator and the set ({})/1 operator. This gives rise to a new primitive goal syntax which reads as follows:

goal         --> module ":" goal
               | receiver "::" goal
               | callable.

receiver     --> package "/" callable
               | reference
               | callable.

Under the hood qualified names are flattened to atoms with the help of an inline atom cache. Further the colon notation will also resolve module names based on the class loader of the call-site, the prefix list of the call-site and the prefix list of the system. A qualified predicate will be also searched in the re-export chain of the given module name.

Examples:
?- basic/lists:member(X, [1]).
X = 1
?- 'jekpro.frequent.basic.lists\bmember'(X, [1]).
X = 1

Finally there is also a double colon notation based on the (::)/2 operator that can be used to send message to a receiver. The receiver itself is prepended Python style to the callable before invoking it. For auto loaded Java classes the re-export chain contains the super class and implemented interfaces. If an unqualified predicate with the same name is defined, then this fall-back is called.

Examples:
?- 'System':err(X), X::println('abc').
X = 0r47733fca
?- current_error(X), X::write('abc'), X::nl.
abc
X = 0r398aef8b

The predicates sys_callable/1, sys_var/1, sys_functor/3 and sys_univ/2 are the adaptations of callable/1, var/1, functor/3 and (=..)/2 in that these predicates respect the module colon (:)/2 and receiver double colon (::)/2 notation. A qualified functor may only contains the colon (:)/2 notation. The predicate sys_get_module/2 can be used to retrieve the class reference or module name of a receiver.

The following qualified names predicates are provided:

M:C:
The predicate calls the callable C by qualifying the predicate name of C by the module name M. The call is performed in the same call-site as the colon notation.
R::C:
The predicate calls the callable C by qualifying the predicate name of C by the module name of R and prepending R itself. The call is performed in the same call-site as the colon notation.
sys_callable(T):
Check whether T is a fully qualified callable.
sys_var(T):
Check whether T is a half qualified or not a qualified callable.
sys_functor(T, F, A):
The predicate unifies F with the possibly quantified functor of T and unifies A with the arity of T.
sys_univ(T, [F|L]):
The predicate unifies F with the possibly qualified functor of T and unifies L with the arguments of T.
sys_get_module(O, M):
The predicate succeeds in M with the class reference or module name of O.
sys_replace_site(Q, S, P):
The predicate succeeds for a new callable B which is a clone of the callable A with all the site properties of the callable Q.

The following qualified names evaluable functions are provided:

M:E:
The function evaluates the expression E by qualifying the function name of E by the module name M. The evaluation is performed in the same call-site as the colon notation.
R::E:
The function evaluates the expression E by qualifying the function name of E by the module name of R and prepending R itself. The evaluation is performed in the same call-site as the colon notation.

Kommentare