scryer-prolog icon indicating copy to clipboard operation
scryer-prolog copied to clipboard

Superfluous (is)/2?

Open triska opened this issue 2 years ago • 1 comments

With p/2 defined as:

p(A, B) :-
        B is A + 3.

I get:

?- wam_instructions(p/2, Is),
   maplist(portray_clause, Is).
get_variable(x(3),1).
put_value(x(2),1).
add(x(3),3,1).
execute(is,2).

Can the execute(is,2) be removed? It seems that "adding 3", i.e., add(...) is everything that's needed here, if that primitive can be made to unify the result directly with B.

triska avatar Sep 04 '23 18:09 triska

The add puts the sum into an intermediary value vector that's read by is/2.

mthom avatar Sep 04 '23 18:09 mthom