So far I've been writing Bicicleta/sigma-calculus code with a separate
self-name per method:

    point = {
        x = 3
        y = 4
        point.r = sqrt((point.x * point.x) + (point.y * point.y))
        point.theta = atan2(point.x, point.y)
    }

But there's no power reason for each method to have a separate name
for "self"; if you pick a fresh name, you can safely use it for all
the methods.  Specifying the name on each method makes the code more
verbose, and using different names on different methods makes the code
obscure.

So, inspired by OCaml, I am going to use a new notation that avoids
repeating the name:

    point = {|p|
        x = 3
        y = 4
        r = sqrt((p.x * p.x) + (p.y * p.y))
        theta = atan2(p.x, p.y)
    }

I can change the notation for display, say in case of inheritance:

    cylindrical_point = point { |self|
        z = 6.25
        r = sqrt((self.x * self.x) + (self.y * self.y) + (self.z * self.z))
    }

whose value displays as

    cylindrical_point = point { |self|
        z = 6.25  # 6.25
        r = sqrt((self.x * self.x) + (self.y * self.y) + (self.z * self.z))
                  # 8.0039053
        # inherited from point:
        x = 3     # 3
        y = 4     # 4
        theta = atan2(self.x, self.y)  # 0.6435011
    }

This change in the display of theta, I think, will somewhat clarify
the nature of inheritance to the novice.

The presentation of the self-name on the screen in the IDE may be
something slightly different from vertical bars around the name.

Reply via email to