2 Matching Annotations
  1. Oct 2023
    1. RING STRUCTURE

      Ivan writes about a concept called "Ring Structure". This is a way of organizing and linking different elements or components in a system.

      In simpler terms, imagine you have a bunch of different objects (like points and lines in a drawing program like Sketchpad). You want to keep track of how these objects are related to each other. For example, you might want to know all the lines that end at a particular point.

      To do this, Ivan uses a "ring structure". Each object has a "string of pointers" - basically a list of references to other objects. This list is circular - the last item in the list points back to the first item. This makes it easy to move forwards and backwards through the list.

      Each object has two "registers" or slots for keeping track of these relationships. One slot is for the object itself, and the other is for the list of related objects.

      Ivan uses the terms "hen" and "chicken" to describe these slots. The "hen" is the object itself, and the "chicken" is the list of related objects.

      Here's a simple Python code example to illustrate this concept:

      ```python class Point: def init(self): self.hen = self self.chickens = []

      class Line: def init(self, point1, point2): self.hen = self self.chickens = [point1, point2] point1.chickens.append(self) point2.chickens.append(self) ```

      In this example, a Point object has a hen that refers to itself and a list of chickens that will contain any Line objects that end at this point. When a Line is created, it adds itself to the chickens list of its end points.

      The "ring structure" is a way to organize and link different elements in a system, making it easier to find and update related elements.

    2. MNEMONICS AND CONVENTIONS

      Mnemonics for Registers: Instead of remembering numerical indices, we use human-readable keys.

      python point = {'TYPE': 'Point', 'PVAL_X': 5, 'PVAL_Y': 10}

      Flexibility: If we want to change the internal structure, we can easily do so by changing the keys.

      ```python

      Changing 'PVAL_X' to 'X_COORD'

      point = {'TYPE': 'Point', 'X_COORD': 5, 'PVAL_Y': 10} ```

      Conventions:

      • The first component ('TYPE') indicates the type of element.
      • Numerical information like coordinates is stored at the end.

      python line = {'TYPE': 'Line', 'START': 'point1', 'END': 'point2', 'LENGTH': 7.2}

      Pointers and Topology: We can use pointers (references) to other elements to establish relationships.

      python point1 = {'TYPE': 'Point', 'PVAL_X': 1, 'PVAL_Y': 1} point2 = {'TYPE': 'Point', 'PVAL_X': 4, 'PVAL_Y': 5} line = {'TYPE': 'Line', 'START': point1, 'END': point2}

      Relocation: If we move point1 to a new variable, we update the pointer in line.

      python new_point1 = point1 # Relocating point1 to new_point1 line['START'] = new_point1 # Updating the pointer

      Segregation of Data: Numerical data is at the end, so if we need to move elements, the numerical data remains untouched.

      ```python

      Even if we relocate, the numerical data ('PVAL_X' and 'PVAL_Y') remains the same.

      ```