Skip to content

Commit

Permalink
feat(#3001): cage.it
Browse files Browse the repository at this point in the history
  • Loading branch information
maxonfjvipon committed Apr 3, 2024
1 parent 63b0755 commit 719781d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
5 changes: 3 additions & 2 deletions eo-runtime/src/main/eo/org/eolang/cage.eo
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@
# you to store objects, not only data. In other words, it doesn't
# do dataization when objects are being stored.
[] > cage
# Make new `cage` for an object.
[object] > new /?
# Make new `cage` for an object. After application this `new` object starts behave
# like `it` object.
[it] > new /?
6 changes: 3 additions & 3 deletions eo-runtime/src/main/java/EOorg/EOeolang/EOcage$EOnew.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ public final class EOcage$EOnew extends PhDefault implements Atom {
*/
EOcage$EOnew(final Phi sigma) {
super(sigma);
this.add("object", new EOcage$EOnew.AtEncaged());
this.add("it", new EOcage$EOnew.AtEncaged());
this.add(
"encage",
new AtSimple(
new PhWrite(
this,
"object",
"it",
rho -> new Data.ToPhi(true)
)
)
Expand All @@ -80,7 +80,7 @@ public final class EOcage$EOnew extends PhDefault implements Atom {

@Override
public Phi lambda() throws Exception {
return this.take("object");
return this.take("it");
}

/**
Expand Down
10 changes: 10 additions & 0 deletions eo-runtime/src/test/eo/org/eolang/cage-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,13 @@
QQ.io.stdout > @
stack-overflow-message
FALSE

# Test.
[] > applies-after-retrieval
# Func.
[x] > func
2.plus x > @
cage.new func > c
eq. > @
c.it 5
7

0 comments on commit 719781d

Please sign in to comment.