Implement :as and :distinct clauses for patterns.