Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!sunybcs!sbcs!thom From: thom@sbcs.sunysb.edu (Thom Fruhwirth) Newsgroups: comp.lang.prolog Subject: Prolog Book Critique Message-ID: <3204@sbcs.sunysb.edu> Date: 25 Jul 89 15:46:39 GMT Sender: news@sbcs.sunysb.edu Lines: 143 Some remarks on "Prolog User's Handbook - a library of utility programs" by Bogdan Filipic, Ellis Horwood Series in Computers and their Applications, 1988 Despite the main title this book does not introduce Prolog, it is a collection of utility programs for list processing, arithmetic operations, screen managment and procedural constructs. While "Prolog by Example" (Springer) is full of typos and programming errors (but introduces more elaborate examples like a toy lisp interpreter), all predicates in this book work - somehow - and there are few typos. My complaint about this book is that it is inconsistent. Some predicates are defined on a very high level of abstraction, in a specification like style (p.17,p.20,p.25,p.53) (they may be extremely inefficient), most others are implemented in a procedural, cut loaded way. Sometimes both approaches are mixed into the same predicate (see below). As in most Prolog programs I have seen, cut is overused. I also do not like the procedural constructs (like for-loops) introduced into Prolog, but that is a personal statement, as I prefer the declarative side of Prolog. Each predicate is given a page, stating its name, description, mode, definition, remarks, examples and references to other predicates. I would like to see every Prolog program documented in this way, although I miss information about types and backtracking behaviour/determinacy of the predicates. With types I mean primtive types (atom, integer, float, compound, lists). It is important two know about them, especially when built-in predicates are involved. Depending on the system, they may either silently fail or produce a run-time type error when called with wrong types. In the book, some system-predicates are protected against ill-typed calls by type-checking their arguments before (e.g. integer(X), integer(Y), X0, N1 is N-1, fac(N1,F1), F is N*F1. is more like a specification as: max(X,Y,X):- X>=Y,!. max(X,Y,Y). Note this definition is extremely dangerous, as it erroneously succeeds with calls like (?- max(2,1,1)) due to the cut. abs(X,X):- X>=0,!. abs(X,Abs):- X<0, Abs is -X. This is a mixture of procedural and declarative style. Either abs(X,Abs):- X>=0,!, X=Abs. abs(X,Abs):- Abs is -X. abs(X,X):- X>=0. abs(X,Abs):- X<0, Abs is -X. would have done it. On p.112 the author states, that the predicate numbervars/3 is "rarely used" (why did he include it then?) and used to produce more readable output. As numbervars/3 is also used in meta-programming to reify variables, this might indicate that the author is not familiar with higher-order predicates and meta-programming. ---------------- Concluding, I cannot recommend the book. Thom Fruehwirth SUNY at Stony Brook Computer Science Dept. NY 11794-4400