I have a question about abstract syntax trees.
In particular I want to sort several trees with an particular
term order.
How can one define a term order for an AST with the following properties:
- For allmost all terms, the order behaves exactly like the standard built-in order of terms.
- Deeply nested in the AST there are terms of functor pos/6 which denote source-positions. These functors should be ignored in the term order, i.e. all terms of functor pos should compare as equal.
Is is possible to extend the built-in term-order with a special case for 'pos' ?
What is the most efficient solution, what is the most readable solution ?
Maybe I should also mention that our ASTs can be quite big, I just benchmarked one AST, which has 217479 proper functors (ignoring the nullary atoms)