Of course, the language's semantics has to have some algorithmic means to combine these declarations into a complete program definition. And if the language admits recursive definitions, the combined program may contains cycles. So the implementation of a declarative language will often have an imperative flavor, combining recursive elements by incrementally updating the set of definitions.
The question is whether it is still possible for the user to understand the semantics without resorting to reasoning about its possibly-imperative implementation. Specifically, the user shouldn't have to worry about time. If the order in which definitions are combined matters, then the semantics becomes imperative. Worse, if the programming interface allows definitions in multiple files, the order of definition might not even be under the user's control--or worse, it might only be controllable through extra-linguistic means like compiler command-line arguments.
Take as an example a language with open recursion, the ability to define a recursive function in multiple, disparate pieces. If an open recursive function has overlapping cases in separate declarations, the language can handle this in one of several ways:
- Let rules defined "later" take precedence over rules defined "earlier."
- Define a total order on rule specificity, and let more specific rules take precedence over less specific rules.
- Disallow overlapping cases statically.
2 comments:
Maybe this is what you mean by option #3 but I want both #2 and #3 by using the entailment partial order with ambiguous cases rejected. Statically when possible (simple pattern matching) or dynamically when necessary (entailment between boolean guards). There remain expressivity/decidability/performance concerns...
Loveely post
Post a Comment