Skip to content

pure objects #5165

Description

@yegor256

Let's add @Impure annotation to some atoms, such as EOposix$EOφ and EOfile$EOsize.

Then, let's create new decorator PhSticky that should decorate all objects created by new in the code we generate by to-java.xsl.

Let's modify the signature of the Phi.take(String) method. It should return a tuple:

<Phi, Boolean> take(String);

Before calling take() of the decoratee, PhSticky should call toφ() (new method) on it and get φ-expression of the object, for example:

new PhSticky(
  new PhWith(
    new PhMethod(new Random(), "plus"),
    42
  )
).take("times")

This should lead to calculating this expression:

(random.plus 42).times

Then, it should try to find the expression in a static hash map. If it's found, PhSticky should return the object the expression maps to. If not, it should call take(String).

Then, when take(String) returns the result, PhSticky, should save it to the hash map, if the second part of the tuple (boolean) is true.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions