Backtracking vs. Non-Backtracking

Some patterns have different behaviour depending on whether the implementation is backtracking or not:

# This is Python:
if "abc" ^ (IsP ("a") | IsP ("ab")) & IsP ("c"):
   print "must be backtracking"
else:
   print "must be non-backtracking"

Backtracking is the most common implementation – but non-backtracking often has advantages: efficient, predictable and easier for users.

All About Pattern Matching Sam Wilmott
Slide 29 of 37        www.wilmott.ca