By default, a pattern matches a package if any version of the package
matches the pattern. However, some patterns will restrict their subterms to
only match against some versions of a package. For instance, the search
term
will
select any package that depends on a package matching
?depends
(pattern
)pattern
. However,
pattern
will only be checked against the versions
of the package that actually satisfy a dependency. This means that if
foo
depends on bar (>= 3.0)
and
versions 2.0
, 3.0
, and
4.0
of bar
are available, then in the
search pattern
, only
versions ?depends
(?version
(2\.0))3.0
and 4.0
will be tested
against
, and hence
?version
(2\.0)foo
will not be found by this search.
It matters which versions are checked because, as in the example above, some
patterns will match one version but not another. For instance, the pattern
?installed
will only match the version of the package (if any) that is
currently installed. Similarly, the pattern
will
only match versions that have the given
?maintainer
(maintainer
)maintainer
. Normally all versions of a package
have the same maintainer, but this is not always the case; in fact, any
search pattern that examines the fields of a package (other than its name,
of course) will behave this way, because all the fields of a package can
change between versions.
![]() | 注意 |
---|---|
There is a subtle, but important, distinction between matching a pattern against a package, and matching it against all the versions of that package. When a pattern is matched against a package, each of its terms is matched against the package, and so each term will match if any version of the package matches. In contrast, when a pattern is matched against each version of a package, it will successfully match if it matches when all its subterms are matched against the same version of the package.
For example: suppose that version |