From cbf2af18e5bcb7d10aa79c446df625548ac7a6ca Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Fri, 9 Aug 2019 16:53:40 -0700 Subject: [PATCH] Prevent definitions from shadowing functions. --- thun/thun.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/thun/thun.pl b/thun/thun.pl index b8cbe81..b5ef23b 100644 --- a/thun/thun.pl +++ b/thun/thun.pl @@ -202,7 +202,9 @@ Definitions joy_def(def(Def, Body)) --> symbol(Def), blanks, "==", joy_parse(Body). -joy_defs --> blanks, joy_def(Def), {assert_def(Def)}, blanks, joy_defs. +joy_def --> joy_def(Def), {ignore(assert_def(Def))}. + +joy_defs --> blanks, joy_def, blanks, joy_defs. joy_defs --> []. assert_defs(DefsFile) :- @@ -210,6 +212,7 @@ assert_defs(DefsFile) :- phrase(joy_defs, Codes). assert_def(def(Def, Body)) :- + \+ func(Def, _, _), retractall(def(Def, _)), assertz(def(Def, Body)).