Want to contribute? Fork us in GitHub!

Rho, Sigma and Other Fantastic Beasts of EO

Since the last blog post, we released a new version of EO where we got rid of the σ (Sigma) attribute. So, this blog post will try to explain all special attributes and assets such as Δ (Delta), φ (Phi), σ (Sigma), λ (Lambda), and ρ (Rho) as promised in one of the previous blog posts.

Where I Was Born

The first special attribute we’re observing (and which was removed) is σ (Sigma). The σ attribute of the object X was the attribute that referred to the object Y inside which the scope object X was born (formed or created for the first time).

The σ attribute in EO:

For example, int.& -> eolang, float.div.& -> float. Consider the next code snippet:

[] > loop
  "Hello, world" > str
  while > @
      stdout > @

Here we have an endless while loop. The second argument of the object while is an anonymous abstract object, let’s call him X. The X object is not used in the scope of the object loop; it’s just created here. The object X will be used inside the scope of the object while when dataization is started. But as you may see X has access to the scope of the object loop via & and may reach the attributes of loop like str.

And we decided that it was a bad idea to give the object such an opportunity to have access to the place where it was born. It kind of breaks the idea of object orientation because & is actually a static attribute like a static method in Java. We don’t tolerate static methods and attributes, here’s why.

Who Uses Me

The second special attribute we’re observing is ρ (Rho). The ρ attribute of the object X is the attribute that refers to the object Y that uses the object X. In EO, the attribute ρ is indicated by the ^ sign. Drawing the analogy with Java, the closest thing to ρ is the this keyword which refers to the current object:

class Animal {
  String type;
  Animal(String tpe) {
    this.type = tpe;
  void voice() {
    System.out.print("I'm a %s", this.type)

Animal cat = new Animal("Cat");
cat.voice();                    // I'm a Cat

Animal dog = new Animal("Dog");
dog.voice();                    // I'm a Dog

Here when we create two instances of Animal - cat and dog. The this keyword inside their functions voice refers to different objects - cat and dog accordingly.

The same functionality can be achieved in EO:

[type] > animal
  [] > voice
    stdout > @
        "I'm a %s"

animal "Cat" > cat
cat.voice > moew   # I'm a Cat

animal "Dog" > dog
dog.voice > woof   # I'm a Dog

The main difference between this in Java and ρ in EO is the moment when these “links” actually become referred to the objects. In Java - right after the object is created, in EO - on attribute dispatch. Let’s look a bit closer. The dynamic dispatch in EO is a mechanism of retrieving an attribute from the object. Syntactically it’s implemented via “dot-notation”.

So this is dispatch:


We’re trying to retrieve an attribute voice from the concrete object cat. At the moment we’ve found the attribute voice inside the object cat and ready to return it - the voice attribute is copied and its ρ attribute is initialized with a link to the object cat. Until we touch cat.voice object its ρ attribute refers to Ø (nothing).

A few more examples:

cat.voice > voice1  # voice1.^ -> cat
cat.voice > voice2  # voice2.^ -> cat
dog.voice > voice3  # voice3.^ -> dog

cat.voice > voice4  # voice4.& -> animal - deprecated
dog.voice > voice5  # voice5.& -> animal - deprecated

What I Decorate

The third special attribute we’re observing is φ (Phi). We’ve already described the attribute in one of the previous blog posts, but let’s dive a bit deeper. In EO, the attribute is indicated by @ sign. The attribute is not mandatory and may be absent. The φ attribute of the object X is the attribute that refers to the object Y which object X decorates. The main purpose of decoration - reuse of the attributes. For example:

[type] > animal
  [] > voice
    stdout > @
        "I'm a %s"

[] > cat
  animal "Cat" > @

Here we have an object cat which decorates an object animal with type attribute set to "Cat". That means that all the attributes which are allowed to be taken from the object animal, like voice, are allowed to be taken from the object cat:

cat.voice > meow # I'm a Cat

The decoration may have several layers and all the attributes on the deepest level are available on the top level:

[type] > animal
  [] > voice
    stdout > @
        "I'm a %s"

[color] > cat
  animal > @
      "%s cat"

[] > black-cat
  cat "black" > @

Here the object black-cat decorates the object cat and the object cat decorates the object animal. This onion of decorators allows taking the attribute voice from the object black-cat:

black-cat.voice > meow # I'm a black cat

What Data I Have

The fourth special thing we’re observing is Δ (Delta) asset. A few words about this asset:

What I Can Reach from Outside

The last special thing we’re observing is λ (Lambda) asset. Let’s look at it a bit closely:

[] > mars-termerature /float # measures the temperature on Mars and returns float

mars-temperature.div 10 > divided

Here, as you may see, mars-termerature is the atom that does not have an attribute div and returns float. However, we can still retrieve the attribute div from it. It will go to the λ asset, execute it, do some calculations, return us some float, and the div attribute will be taken from this float.

That’s all for today. We’ll be right back in a week with a new fresh blog post. Stay in touch.