Dear all,
representation_error(max_arity) is defined relative to the max_arity flag. That's fine for predicates like functor/3 and (=..)/2, but it's also specified for predicate-indicator predicates like abolish/1 and current_predicate/1.
The trouble is that some systems make compound-term arity unbounded (or quite large) while still limiting predicate arity. On SWI:
?- functor(H, foo, 2000). % ok ?- functor(H, foo, 2000), assertz(H). % representation_error(max_procedure_arity)
SWI Prolog solves the issues by splitting max_arity from max_procedure_arity (the latter isn't ISO). Eclipse Prolog also has two different limits but error is underreported (ambiguous). Picat, although not a Prolog system, also has two different limits (probably rooted in B-Prolog).
That is definitely a problem and most of the ISO tests suites I have available either fail here or ignore those cases. Some possible directions:
a) force one limit for terms and predicates (simplest but not a solution) b) raise limit for predicate arity (but that can be a *significant* implementation effort with low ROI) c) use max_procedure_arity (and push for future standardization) d) keep reporting max_arity for both limits, use error context (not standard) to disambiguate which arity limit has been reached
I lean towards (c) looking for a possible change in the standard, or (d) as a temporary solution.
(b) is difficult because some limits are intrinsically hard to raise in some engines (every reasonable computer language has some kind of procedure argument limits). A fallback calling convention may help but the implementation cost is not trivial.
What are your opinions?
Thanks,