Commits

Carl Friedrich Bolz committed eda6d5c

rename and simplify copy_and_basic_unify

  • Participants
  • Parent commits 9253070

Comments (0)

Files changed (1)

File prolog/interpreter/term.py

             other._unify_derefed(copy, heap)
             return copy
         else:
-            return self.copy_and_basic_unify(other, heap, env)
-    
-    def copy_and_basic_unify(self, other, heap, env):
-        raise NotImplementedError("abstract base class")
-    
+            return self.basic_unify_and_standardize_apart(other, heap, env)
+
+    def basic_unify_and_standardize_apart(self, other, heap, env):
+        # good enough default implementation:
+        self.basic_unify(other, heap, False)
+        return self
+
     def enumerate_vars(self, memo):
         return self
 
             raise UnificationFailed
     
     @jit.unroll_safe
-    def copy_and_basic_unify(self, other, heap, env):
+    def basic_unify_and_standardize_apart(self, other, heap, env):
         if (isinstance(other, Callable) and
             self.signature().eq(other.signature())):
             for i in range(self.argument_count()):
     def signature(self):
         return self._signature
 
+    def basic_unify_and_standardize_apart(self, other, heap, env):
+        if not isinstance(other, Atom):
+            return Callable.basic_unify_and_standardize_apart(self, other, heap, env)
+        if not self.signature().eq(other.signature()):
+            raise UnificationFailed
+
+
 class Numeric(NonVar):
     __slots__ = ()
 
         if isinstance(other, Number) and other.num == self.num:
             return
         raise UnificationFailed
-    
-    def copy_and_basic_unify(self, other, heap, env):
-        if isinstance(other, Number) and other.num == self.num:
-            return self
-        else:
-            raise UnificationFailed
-    
+
     def __str__(self):
         return repr(self.num)
     
             return
         raise UnificationFailed
 
-    def copy_and_basic_unify(self, other, heap, env):
-        if isinstance(other, BigInt) and other.value.eq(self.value):
-            return self
-        raise UnificationFailed
-
     def __str__(self):
         return repr(self.value)
 
         if isinstance(other, Float) and other.floatval == self.floatval:
             return
         raise UnificationFailed
-    
-    def copy_and_basic_unify(self, other, heap, env):
-        if isinstance(other, Float) and other.floatval == self.floatval:
-            return self
-        else:
-            raise UnificationFailed
-    
+
     def __str__(self):
         return repr(self.floatval)
     
                     return False
             return True
 
-        def copy_and_basic_unify(self, other, heap, env):
+        def basic_unify_and_standardize_apart(self, other, heap, env):
             if not isinstance(other, abstract_callable):
-                return Callable.copy_and_basic_unify(self, other, heap, env)
+                return Callable.basic_unify_and_standardize_apart(self, other, heap, env)
             if self.signature().eq(other.signature()):
                 for x in arg_iter:
                     a = getattr(self, 'val_%d' % x)