PLOGHELP OLDPLOGTERMS Jonathan Laventhol, 22 July 1985. This file explains the changes made in Version 11 to the representation of Prolog terms in the POPLOG Prolog system. For details of new procedures for manipulating Prolog terms and how to use the new system see HELP *TERMSINPOP. The procedures described in TERMSINPOP are now the preferred ones, although the old Prolog term manipulators will still be available for an interim period. -- PROLOG COMPLEX TERMS ----------------------------------------------- Prolog complex terms come in two kinds, pairs and other complex terms. The 'other' kind are the most common: foo(apples, pears) Previously this would have been represented by the vector {apples pears foo} Now, terms like this have their own datatype, "prologterm", which are constructed from the term's functor and arguments. The POP11 procedure prolog_maketerm is given the functor and arity of the term and takes the term's arguments from the stack to construct the prologterm, thus "apples", "pears"; prolog_maketerm("foo", 2) => ** One consequence of this new representation is that vectors now have no special significance to the Prolog system and may be made part of Prolog datastructures if required. However, the internal elements will now be invisible to Prolog, as it never looks inside them. PROLOG_PREDWORD is now PROLOG_FUNCTOR The old procedure prolog_predword, which returns the functor of the given term has been replaced with prolog_functor. The main difference between these is that the old procedure produced a mishap if it were not given a Prolog complex term or nil or an atom. prolog_functor, in such a case, will return its argument. Note that prolog_functor will return its argument even if it is a variable -- both prolog_predword and the Prolog predicate functor/3 would cause a mishap. PROLOG_NARGS is now PROLOG_ARITY prolog_nargs which returns the arity of the given term has been superceded by prolog_arity. Both have exactly the same behaviour. -- PROLOG VARIABLES --------------------------------------------------- Prolog variables consist of the datastructure "prologvar" which is structurally the same as a reference (see HELP *REFERENCES), in that it has a single field known as the "content". Previously, the content of an uninstantiated Prolog variable was the POPLOG word "undef" -- this meant that the unification of any such variable with the Prolog atom 'undef' was not possible. In the new Prolog system however, an uninstantiated Prolog variable is represented as a prologvar whose content is itself. A further change concerning uninstantiated Prolog variables is in the way in which they are printed in POP11. Rather than just printing the value "undef" in their content, they now print with their identifying numbers, which are the same numbers as the print with in Prolog. This means you can tell which are unified with which -- as always should have been the case. -- UNIFY -------------------------------------------------------------- The procedure unify(item1, item2, contn) has been renamed prolog_unifyc (contrasted with prolog_unify). This procedure unifies item1 with item2, and if successful, applies its continuation argument. ------------