top | item 23602641

(no title)

downerending | 5 years ago

In Prolog, backtracking is a fundamental feature of the language, and idiomatic code can do it places you might not think of.

Part of writing efficient Prolog is doing things to avoid such backtracking (by adding cuts or rearranging code).

Bit-blitting is just an example I made up for "large-scale manipulation of array data". There are such cases where backtracking would likely make more sense, though I'm not thinking of an obvious one right now.

discuss

order

tom_mellior|5 years ago

The reason you have trouble thinking of an example is that there isn't one. If you know enough Prolog to write idiomatic Prolog code, you also know enough Prolog to think of the cases where your code will backtrack and where it won't. Because idiomatic Prolog code doesn't do unnecessary backtracking.

YeGoblynQueenne|5 years ago

That. Prolog will backtrack to get all solutions to a goal, but there is no reason why a goal must have multiple solutions. Unless you program it that way yourself.

downerending|5 years ago

You may well be right. As far as I can recall, though, as of the last time I was regularly using Prolog, trying to do serious work on a (say) 1000x1000 array was a recipe for disaster.

The exception would be Turbo Prolog, but it was a rather restrictive subset of the language. Fast as hell, though.