Some particularly complex searches can be expressed in
aptitude using explicit targets.
In normal search expressions, there is no way to refer to
the package or version that is currently being tested. For
instance, suppose that you want to search for all packages
P
that depend on a second package
Q
such that
Q
recommends
P
. Clearly you need to start out
with a
term. But the
term filling in the ?depends
(...)...
needs to somehow
select packages that are identical to the one being matched
against
. When describing the
goal above, I dealt with this by giving the packages names,
calling them ?depends
P
and
Q
; terms with explicit targets
do exactly the same thing.
[17]
An explicit target is introduced by the ?for
term:
This behaves exactly like pattern
,
but variable
can be used within
pattern
to refer to the package or
version that pattern
is being
matched against. You can use
variable
in two ways:
The term ?=
will match exactly the package or
version indicated by the given variable. Specifically:
if the corresponding ?for
term is limited to a
particular version, then ?=
will match either that
version (if ?=
is limited) or the whole package;
otherwise it will match any version of the package.
See Example 2.2, “
Use of the ?=
term.
” for an example
of how to use ?=
.
The term
will match
any package or version if the value of
?bind
(variable
,
pattern
)variable
matches against
pattern
.
For ?
-style terms, a shorthand
form is available. The expression
can be replaced by
?bind
(variable
,
?term
[(args
)])?
.
variable
:term
(args
)
See Example 2.3, “Use of the ?bind
term” for an example
of how to use ?bind
.
[17]
Astute readers will note that this is essentially a way
to explicitly name the variable in the λ-terms
corresponding to the term. A typical term would
have the form “λ
x
. name-equals(x
,
pattern
)”; giving this
an explicit target makes x
visible in the search language.