5 ms·
Recursion is fine, as long as an argument gets smaller at every iteration, since that guarantees termination.
by codebje 7y ago
Recursion is fine, as long as an argument gets smaller at every iteration, since that guarantees termination.
- ignaloidas 7y agoOh, like Ackermann function[0]? Because I wouldn't want my server try to evaluate that. [0] https://en.wikipedia.org/wiki/Ackermann_function https://en.wikipedia.org/wiki/Ackermann_function
- cryptonector 7y agoExactly. And heck, even with loops that are guaranteed to terminate, you can loop long enough to have that be a problem. You really want to have no loops at all, like DTrace and eBPF, or else you want to give up on this idea of not being Turing-complete. You have to decide how critical it is to be able to put a reasonable bound on the run-time of a function.
- Quekid5 7y agoSince there are no side effects in Dhall you can always just impose an arbitrary timeout if you really want to. IME, it's really rare to stumble upon pathological complexity like the Ackermann function. You basically have to go out of your way to do 'absurd' things. (The point is of course taken, but personally I don't really care much about the TC-ness or otherwise of Dhall, though it is kind a nice-to-have to ensure that you don't accidentally introduce infinite loops.)