Because expression evaluation runs outside the usual
stack limits, can I use it to bomb a pengin or SWISH?
Thats strange, because in many other scenarios you have
configurable stack limit. Why the exception of this rule?
bomb(f(X,Y)) :- bomb(X), bomb(Y).
?- bomb(X).
ERROR: Stack limit (1.0Gb) exceeded
Since it says stack limit, why is this not the same stack limit
as well for expression evaluation? Assume you have a resource
quota in (is)/2, you can get rid of the cycle test.
Here is a sketch of a post mortem analysis, even written in 100%
pure Prolog, which gives an error analysis service:
X is Y :-
catch(eval(Y,X), error(foo,_),
(acyclic_term(Y) -> throw(error(bar,_)); throw(error(baz,_)))).
The single error “foo” produced by the internal eval/2 predicate
is changed into either an error “bar” or an error “baz”, to provide the
end-user some more information. Can be also implemented
natively by the builtin is/2, making a cycle test during eval/2
unnecessary, since acyclic_term/1 exists. Or is there a danger
that acyclic_term/1 crashes? It probably uses less stack than eval/2.