Open UWN opened 2 years ago
Is this predicate useful on the Prolog-level? This seems to be an error that would most likely be thrown by the engine itself instead of by Prolog programs (within Prolog code). For example, there seems no way to tell, within Prolog, whether there is sufficient memory to allocate a term. Is there currently a situation where a Prolog program could throw this error by itself and would already benefit from this predicate? Maybe if it itself catches such an error that is generated by the engine, and then wants to throw a resource error itself, is it intended for such situations?
See the definition of length/2. Like length(L,L)
. Here, it is evident that this computation will take infinitely long. And thus it is legitimate to shorten the time by throwing immediately a resource error.
And what about the module qualification? How else is it possible to tell which definition is meant?
Like
length(L,L)
. Here, it is evident that this computation will take infinitely long.
I don't understand why this is the case. I think the obvious thing to do here would be to make the predicate fail, because L
needs to be both a list and an integer, which is impossible. This doesn't seem to clash with the declarative description of length/2
given here.
This doesn't seem to clash with the declarative description of
length/2
Right. But it has undesirable properties when porting a program from one implementation to another. The use of Brent or (previously) Floyd is relatively recent, like 2007. Also, making such an ad hoc improvement, when related predicates don't, seems to be quite odd. Think of ?- append(L,L,L).
And, lest I forget, length(L,L)
can only produce that resource error immediately, if L
is unattributed.