uses([Object as Alias, ...])
Declares object aliases. Typically used to shorten long object names, to simplify and consistently send messages to parameterized objects, and to simplify using or experimenting with different object implementations of the same protocol when using explicit message sending. Object aliases are local to the object (or category) where they are defined.
The objects being aliased can be parameter variables or parametric objects where one of more parameters are parameter variables when using the directive in a parametric object or a parametric category defined in a source file (the common case).
Declaring multiple aliases for the same object is allowed. But repeated declarations of the same alias, declaring an alias for an object alias, and redefining an alias to reference a different object are reported as compilation errors.
To enable the use of static binding, and thus optimal message sending performance, the objects should be loaded before compiling the entities that call their predicates.
Template and modes
:- object(foo(_HeapType_, _OptionsObject_)). :- uses([ fast_random as rnd, time(utc) as time, heap(_HeapType_) as heap, _OptionsObject_ as options ]). bar :- ..., % the same as fast_random::permutation(L, P) rnd::permutation(L, P), % the same as heap(_HeapType_)::as_heap(L, H) heap::as_heap(L, H), % the same as _OptionsObject_::get(foo, X) options::get(foo, X), % the same as time(utc)::now(T) time::now(T), ...