Skip to content

pure objects #4812

@yegor256

Description

@yegor256

Instead of #4411 and #4535

The compiler can mark some objects as "pure" (similar to a pure function that always returns the same value if its arguments are the same).

An object is pure if it doesn't have lambda and all its kids are pure.

Also, an object can be made pure by adding apostrophe to its name:

[a b] > sum' ?

Here, the object sum is pure, but a copy of it may be not-pure (depending on a and b).

The compiler can wrap pure objects in PhPure decorator that simply caches the lambda() call.

In runtime, when a pure abstract object is used in application, the results becomes pure if all arguments are pure.

We can add .pure() function to the Phi interface, in order to enable the detection of purity in runtime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions