shithub: pprolog

Download patch

ref: 67e8b85a9f9b42acc896b44eb2ea1310e749f03a
parent: 2c3e688c3f779f0abfaad887f13ab2b70c9f814a
author: Peter Mikkelsen <peter@pmikkelsen.com>
date: Tue Jun 29 22:01:46 EDT 2021

Treat the variable _ differently, in that it doesn't introduce a new binding

--- a/eval.c
+++ b/eval.c
@@ -169,6 +169,10 @@
 				left = right;
 				right = tmp;
 			}
+
+			if(runestrcmp(left->text, L"_") == 0)
+				continue; /* _ doesn't introduce a new binding */
+
 			Binding *b = malloc(sizeof(Binding));
 			b->name = left->text;
 			b->nr = left->clausenr;
--- a/example.pl
+++ b/example.pl
@@ -32,3 +32,5 @@
 :- initialization(could_be_friends(bob, sam)).
 
 :- initialization(length([a,b,c,d], Len)).
+
+:- initialization(length(_,_)).
\ No newline at end of file