Hi, I've also playing with functional objects e.g. objects that updates functionally meaning that the objects are non mutating. I added a little suger to handle this in my python to prolog compiler and now we can do this:
module(f)
# Note that the functional parent means that the class is managed using
# functional approach this also constrain that all parent classes is also
# functional else bugs will appear.
class A(functional):
x = 1
def __init__(self,y):
pk('A',self.x)
self.x = y
class B(functional):
y = A(1)
def __init__(self,y):
self.y=y
a = A(2)
b1 = B(a)
# note that when setting things we update create a new object and this is the
# syntactic suger
b2 : b1.y.x = 3 # translates to (set! b2 (fset-x b1 '(y x) 3))
b3 : b2.y.y = 4
pk("b1",b1.y.x)
pk("b2",b2.y.x)
pk("b3",b3.y.y)
# there is a nice scheme interface to use this in pf-objects library in the
# code base