Let us consider a purely declarative language such as SQL, XQuery, or a logic language like Prolog, or a purely functional language without variable mutability.

Considering that the interpreter or compiler for a such language is free of bugs and can check every type errors, could a program written in such language have a side effects which leads to an unwanted behaviour(s) or eventually a runtime error?


2 Answers 2


Yes. Consider, for example, running out of memory. Or, if the program is not 'pure', i/o errors. Or even stuff like division by 0.


For a well-known, mainstream example (I presume), transforms written in XSLT 1.0 (without using any extension functions) are strongly normalizing and (thus) always terminate. XSLT certainly falls in the "fairly" declarative (*) language category, and also only knows about / only allows immutable variables.

No risk of infinite loops for the finite inputs you feed it.

But then, of course, it isn't Turing-complete (without the use of extensions), and one can certainly write transforms which output nothing really useful (or something one didn't quite expect).

Still, I'm not sure if it'd be fair to call such possibilities "failures" because of the language's semantic, strictly speaking.


(* and verbose, but that's another topic)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.