| OCR Text |
Show 32 goal. Proceed is used to continue execution following the successful unification of a goal with a unit clause. To understand the operation of these instructions, consider Figure 3, which shows the WAM code generated for the program of Figure 2 (repeated here). This code is generated by the PLM compiler, an optimized WAM compiler (see Section 2.5.2). When the top-level goal, ?- concatenate (X, Y, [1, 2, 3, 4)] is encountered, the procedure concatenate/3 is invoked. The switch_on_term instruction in-dicates that control is to be passed to the next instruction since the first argument is an unbound variable. There, the try_me_e1se instruction creates a choice point on the stack, indicating that if a unification failure is encountered, the code for the next clause to try is found at label _254. The code for the first clause begins with the next instruction, at label _251. The get_value instruction attempts to unify the second and third arguments; it succeeds, binding Y to the list. The get_ nil instruction attempts to unify the frrst argument with the end-of-list symbol nil, which succeeds, binding x to nil. The proceed instruction indicates that the procedure call succeeded with a unit clause, and control returns to the next goal. There are none in this example. If the unification with the head of the first clause had failed, or if another solu-tion was needed, the code for the second clause (label _ 2 54) would be executed. The trust_me_else instruction indicates that if the following code fails, backtracking should occur. The get_list instruction attempts to unify the first argument with the head of a (new) list. It binds x to the new list on the heap and sets a special pointer to reference the next heap location. It also sets the "mode" of the machine to WRITE, indicating that unification will create a new structure on the heap rather than unifying the term with an existing structure. The head of the new list will be placed there by the unify_ variable instruction, which creates a new (unbound) value cell on the heap. The unify_ cdr instruction creates another (unbound) value cell on the heap to be a place-holder for the uninstantiated tail of the list. The next get _list instruction attempts to unify the third argument with the |