3 ms·
Prolog doesn't have typed variables, but any Prolog term has a type, the set of Prolog terms that unify with itself. In practice, when you write Prolog, your ar
by YeGoblynQueenne 4y ago
Prolog doesn't have typed variables, but any Prolog term has a type, the set of Prolog terms that unify with itself. In practice, when you write Prolog, your arguments to predicates are always implicitly typed, for example if you write a program that takes as argument a list, you'll write something like this:
a_list_processor([H|T], ..., ):-
process_list_head(H,Xs)
,process_list_tail(T,Ys)
, ...
Or at least you learn to do that quickly enough. And note that this implicit typing is used both to select clauses in a predicate, and also to index clauses in the Prolog program database by their first term (in which case the first term better be a constant though, not a list). So it's a bit of a bug-repellent, and a bit of an efficiency booster, both. Just like you get with static types.