Jon Lang wrote:
This can already be done, for the most part:
/ (<.does(ro)>) /
Mind you, this only searches a list; to make it search a tree, you'd
need a drill-down subrule such as I outline above:
/ <[>* (<.does(ro)>) <]>* /
Isn't it the case that ~~ has very special dispatch semantics? First
it is singly dispatched on the lhs, then the rhs determines the
type of match. Now what if the lhs is a Tree? In general ~~ requires
the lhs to provide some kind of iteration interface that the rhs
uses when it e.g. backtracks. For a Tree there will be one default
traversal mode and others can be requested by named arguments.
That being said the interesting question is how much of the rule
syntax can be generalized from string iteration to generic iteration.
Another interesting case is a type as rhs. Here we need to combine
signature matching with quantification.
BTW, IIRC there are signatures in rules but I can't find it in S05.
Where is it?
"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12 -- Srinivasa Ramanujan