9length/2 comes predefined in SWI Prolog. If you put this definition in a file and consult it, you will receive an error message. The solution is to rename the predicate in your definition, e.g. to mylength/2.