diff --git a/eo-maven-plugin/src/main/resources/org/eolang/maven/pre/to-java.xsl b/eo-maven-plugin/src/main/resources/org/eolang/maven/pre/to-java.xsl
index 117d575294..df041b67b0 100644
--- a/eo-maven-plugin/src/main/resources/org/eolang/maven/pre/to-java.xsl
+++ b/eo-maven-plugin/src/main/resources/org/eolang/maven/pre/to-java.xsl
@@ -526,7 +526,7 @@ SOFTWARE.
- "α"
+ "message"
diff --git a/eo-runtime/src/main/eo/org/eolang/bool.eo b/eo-runtime/src/main/eo/org/eolang/bool.eo
index 0a80a76744..63abf4e0fd 100644
--- a/eo-runtime/src/main/eo/org/eolang/bool.eo
+++ b/eo-runtime/src/main/eo/org/eolang/bool.eo
@@ -36,9 +36,6 @@
^.as-bytes
x.as-bytes
- # If true, return "t", otherwise "f".
- [t f] > if /?
-
# NOT.
[] > not
eq. > @
@@ -47,9 +44,9 @@
# AND.
[x] > and
- if. > @
+ if > @
^
- if.
+ if
x
TRUE
FALSE
@@ -57,10 +54,10 @@
# OR.
[x] > or
- if. > @
+ if > @
^
TRUE
- if.
+ if
x
TRUE
FALSE
diff --git a/eo-runtime/src/main/eo/org/eolang/cage.eo b/eo-runtime/src/main/eo/org/eolang/cage.eo
index cb97ae5269..958f54c19a 100644
--- a/eo-runtime/src/main/eo/org/eolang/cage.eo
+++ b/eo-runtime/src/main/eo/org/eolang/cage.eo
@@ -29,40 +29,4 @@
# This object is doing exactly the same as "memory", but allows
# you to store objects, not only data. In other words, it doesn't
# do dataization when objects are being stored.
-# Attention: your program will fail with StackOverflow exception if you try to
-# write to "cage" an object that was obtained by any manipulations with the
-# same "cage".
-# For example, the code below fails
-# [] > example
-# cage > cge
-# plus.
-# 0
-# 0
-# seq > @
-# cge.write
-# plus.
-# cge
-# 1
-# cge
-#
-# The reason of failing is described in detail here:
-# https://github.com/objectionary/eo/issues/1698#issuecomment-1675224923
-# To prevent failing you have to make a copy of "cage" before writing:
-# [] > example
-# cage > cge
-# plus.
-# 0
-# 0
-# seq > @
-# cge.write
-# plus.
-# cge' # <--copy is made here
-# 1
-# cge
-# @todo #1698:60min Make up with an idea how to prevent StackOverflow exception
-# or warn a user if he writes cage into the same cage. Options: 1) xsl file
-# that somehow checks if cage is about to write to the same cage 2) catch
-# StackOverflow exception at the top level and say to the user that maybe he
-# writes cage to the same cage.
-[] > cage /?
-
+[enclosure write] > cage /?
diff --git a/eo-runtime/src/main/eo/org/eolang/error.eo b/eo-runtime/src/main/eo/org/eolang/error.eo
index 5d78d29bb9..28f50c6e90 100644
--- a/eo-runtime/src/main/eo/org/eolang/error.eo
+++ b/eo-runtime/src/main/eo/org/eolang/error.eo
@@ -31,4 +31,4 @@
# The first attempt to dataize it will lead to runtime error and program
# termination. The only way to catch such an error is by using
# the object 'try'.
-[] > error /?
+[message] > error /?
diff --git a/eo-runtime/src/main/eo/org/eolang/float.eo b/eo-runtime/src/main/eo/org/eolang/float.eo
index 86a3f3e577..13daf29c88 100644
--- a/eo-runtime/src/main/eo/org/eolang/float.eo
+++ b/eo-runtime/src/main/eo/org/eolang/float.eo
@@ -37,7 +37,7 @@
nan > nan-as-bytes!
0.0 > pos-zero-as-bytes!
-0.0 > neg-zero-as-bytes!
- if. > @
+ if > @
or.
eq.
x-as-bytes
diff --git a/eo-runtime/src/main/eo/org/eolang/heap.eo b/eo-runtime/src/main/eo/org/eolang/heap.eo
index 95f418c030..2c47ccbdae 100644
--- a/eo-runtime/src/main/eo/org/eolang/heap.eo
+++ b/eo-runtime/src/main/eo/org/eolang/heap.eo
@@ -36,7 +36,7 @@
plus. > new-next!
s
^.malloc.next.as-int
- if. > @
+ if > @
gt.
new-next
size
diff --git a/eo-runtime/src/main/eo/org/eolang/if.eo b/eo-runtime/src/main/eo/org/eolang/if.eo
new file mode 100644
index 0000000000..57aa1be7b7
--- /dev/null
+++ b/eo-runtime/src/main/eo/org/eolang/if.eo
@@ -0,0 +1,32 @@
+# The MIT License (MIT)
+#
+# Copyright (c) 2016-2024 Objectionary.com
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
++architect yegor256@gmail.com
++home https://github.com/objectionary/eo
++package org.eolang
++rt jvm org.eolang:eo-runtime:0.0.0
++version 0.0.0
+
+# Control structure that allows for conditional execution of code.
+# It evaluates a condition, which is a `bool` object, and behaves as `left` if the condition is
+# `TRUE`. If the condition evaluates to `FALSE` - behaves as `right`.
+[condition left right] > if /?
diff --git a/eo-runtime/src/main/eo/org/eolang/memory.eo b/eo-runtime/src/main/eo/org/eolang/memory.eo
index df1e1b49c1..5c76ef394a 100644
--- a/eo-runtime/src/main/eo/org/eolang/memory.eo
+++ b/eo-runtime/src/main/eo/org/eolang/memory.eo
@@ -29,4 +29,4 @@
# Storage of data in memory.
# @todo #2211:30min We can implement memory in EO instead of Java and let it use
# ram object. Let's not forget to update the "Origins of Objects" paper.
-[] > memory /bytes
+[enclosure write] > memory /bytes
diff --git a/eo-runtime/src/main/eo/org/eolang/negative-infinity.eo b/eo-runtime/src/main/eo/org/eolang/negative-infinity.eo
index a6dc0a2e0c..8a4e38d632 100644
--- a/eo-runtime/src/main/eo/org/eolang/negative-infinity.eo
+++ b/eo-runtime/src/main/eo/org/eolang/negative-infinity.eo
@@ -85,10 +85,10 @@
num.eq -0.0
num.eq 0.0
num.eq 0
- if. > @
+ if > @
is-nan-or-zero value
nan
- if.
+ if
is-num-gt-zero value
negative-infinity
positive-infinity
@@ -101,7 +101,7 @@
# Here we check if 'num' is nan by comparing it with nan bytes, because 'num' is cached bytes.
[num] > is-nan
num.eq nan.as-bytes > @
- if. > @
+ if > @
or.
is-nan value
value.eq pos-inf-as-bytes
@@ -116,7 +116,7 @@
# Here we check if 'num' is nan by comparing it with nan bytes, because 'num' is cached bytes.
[num] > is-nan
num.eq nan.as-bytes > @
- if. > @
+ if > @
or.
is-nan value
value.eq neg-inf-as-bytes
@@ -146,10 +146,10 @@
[e]
0.0.lte num > @
FALSE
- if. > @
+ if > @
is-nan-or-infinite value
nan
- if.
+ if
is-num-gte-zero value
negative-infinity
positive-infinity
diff --git a/eo-runtime/src/main/eo/org/eolang/positive-infinity.eo b/eo-runtime/src/main/eo/org/eolang/positive-infinity.eo
index a9d9cdd239..28915fb5d4 100644
--- a/eo-runtime/src/main/eo/org/eolang/positive-infinity.eo
+++ b/eo-runtime/src/main/eo/org/eolang/positive-infinity.eo
@@ -85,10 +85,10 @@
[e]
0.0.lt num > @
FALSE
- if. > @
+ if > @
is-nan-or-zero value
nan
- if.
+ if
is-num-gt-zero value
positive-infinity
negative-infinity
@@ -101,7 +101,7 @@
# Here we check if 'num' is nan by comparing it with nan bytes, because 'num' is cached bytes.
[num] > is-nan
num.eq nan.as-bytes > @
- if. > @
+ if > @
or.
is-nan value
value.eq neg-inf-as-bytes
@@ -116,7 +116,7 @@
# Here we check if 'num' is nan by comparing it with nan bytes, because 'num' is cached bytes.
[num] > is-nan
num.eq nan.as-bytes > @
- if. > @
+ if > @
or.
is-nan value
value.eq pos-inf-as-bytes
@@ -147,10 +147,10 @@
[e]
0.0.lte num > @
FALSE
- if. > @
+ if > @
is-nan-or-infinite value
nan
- if.
+ if
is-num-gte-zero value
positive-infinity
negative-infinity
diff --git a/eo-runtime/src/main/eo/org/eolang/switch.eo b/eo-runtime/src/main/eo/org/eolang/switch.eo
index 48bb6aeddb..cb1f17cf2b 100644
--- a/eo-runtime/src/main/eo/org/eolang/switch.eo
+++ b/eo-runtime/src/main/eo/org/eolang/switch.eo
@@ -47,17 +47,17 @@
# If case key is TRUE, return case value.
# Otherwise take next case.
[index] > case-at
- if. > @
+ if > @
index.eq ^.len
TRUE
- if.
+ if
at.
^.cases.at index > case
0
case.at 1
^.case-at
index.plus 1
- if. > @
+ if > @
len.eq 0
error "switch cases are empty"
case-at 0
diff --git a/eo-runtime/src/main/eo/org/eolang/tuple.eo b/eo-runtime/src/main/eo/org/eolang/tuple.eo
index 5712d387c7..99524eec7d 100644
--- a/eo-runtime/src/main/eo/org/eolang/tuple.eo
+++ b/eo-runtime/src/main/eo/org/eolang/tuple.eo
@@ -54,16 +54,16 @@
[i] > at
i > idx!
^.length > len
- if. > index!
+ if > index!
0.gt idx
len.plus idx
idx
- if. > @
+ if > @
or.
0.gt index
len.lte index
error "Given index is out of tuple bounds"
- if.
+ if
gt.
len.plus -1
index
diff --git a/eo-runtime/src/main/java/EOorg/EOeolang/EOerror.java b/eo-runtime/src/main/java/EOorg/EOeolang/EOerror.java
index 54c0a12232..5f90eb192f 100644
--- a/eo-runtime/src/main/java/EOorg/EOeolang/EOerror.java
+++ b/eo-runtime/src/main/java/EOorg/EOeolang/EOerror.java
@@ -59,7 +59,7 @@ public final class EOerror extends PhDefault implements Atom {
*/
public EOerror(final Phi sigma) {
super(sigma);
- this.add("α", new AtFree());
+ this.add("message", new AtFree());
}
/**
@@ -83,7 +83,7 @@ public static String message(final Throwable exp) {
@Override
public Phi lambda() {
- throw new ExError(this.attr("α").get());
+ throw new ExError(this.attr("message").get());
}
/**
diff --git a/eo-runtime/src/main/java/EOorg/EOeolang/EObool$EOif.java b/eo-runtime/src/main/java/EOorg/EOeolang/EOif.java
similarity index 79%
rename from eo-runtime/src/main/java/EOorg/EOeolang/EObool$EOif.java
rename to eo-runtime/src/main/java/EOorg/EOeolang/EOif.java
index 475b8ded0b..c955a07e47 100644
--- a/eo-runtime/src/main/java/EOorg/EOeolang/EObool$EOif.java
+++ b/eo-runtime/src/main/java/EOorg/EOeolang/EOif.java
@@ -38,30 +38,31 @@
/**
* IF.
*
- * @since 1.0
+ * @since 0.36.0
* @checkstyle TypeNameCheck (5 lines)
*/
@Versionized
-@XmirObject(oname = "bool.if")
-public final class EObool$EOif extends PhDefault implements Atom {
+@XmirObject(oname = "if")
+public final class EOif extends PhDefault implements Atom {
/**
* Ctor.
* @param sigma Sigma
*/
- public EObool$EOif(final Phi sigma) {
+ public EOif(final Phi sigma) {
super(sigma);
- this.add("t", new AtFree());
- this.add("f", new AtFree());
+ this.add("condition", new AtFree());
+ this.add("left", new AtFree());
+ this.add("right", new AtFree());
}
@Override
public Phi lambda() {
- final boolean term = new Param(this).strong(Boolean.class);
+ final boolean term = new Param(this, "condition").strong(Boolean.class);
final Phi out;
if (term) {
- out = this.attr("t").get();
+ out = this.attr("left").get();
} else {
- out = this.attr("f").get();
+ out = this.attr("right").get();
}
return out;
}
diff --git a/eo-runtime/src/test/eo/org/eolang/bool-tests.eo b/eo-runtime/src/test/eo/org/eolang/bool-tests.eo
index 92dcb1d5e0..62928f5e94 100644
--- a/eo-runtime/src/test/eo/org/eolang/bool-tests.eo
+++ b/eo-runtime/src/test/eo/org/eolang/bool-tests.eo
@@ -47,15 +47,6 @@
TRUE
42
-# Test.
-[] > forks-on-condition
- eq. > @
- if.
- 5.eq 8
- 123
- 42
- 42
-
# Test.
[] > iterates-over-simple-counter
memory 0 > x
@@ -161,7 +152,7 @@
arr.length.minus 1 > max
seq > res
*
- if.
+ if
max.eq 0
acc.write
acc.as-int.plus
@@ -190,7 +181,7 @@
arr.length.minus 1 > max
seq > nop
*
- if.
+ if
max.eq 0
acc.write
acc.as-int.plus
@@ -221,7 +212,7 @@
*
while.
[]
- if. > @
+ if > @
iter.as-int.lt max
seq
*
@@ -249,7 +240,7 @@
*
while.
[]
- if. > @
+ if > @
iter.as-int.lt max
seq
*
diff --git a/eo-runtime/src/test/eo/org/eolang/cage-tests.eo b/eo-runtime/src/test/eo/org/eolang/cage-tests.eo
index c71539278d..ab97274fcc 100644
--- a/eo-runtime/src/test/eo/org/eolang/cage-tests.eo
+++ b/eo-runtime/src/test/eo/org/eolang/cage-tests.eo
@@ -42,16 +42,16 @@
# Test.
[] > avoid-infinite-loop
cage > x
- TRUE.if
+ if
x' > copy
eq. > @
seq
*
x.write
- TRUE.if 1 0
+ if TRUE 1 0
copy.<
x.write
- TRUE.if copy 0
+ if TRUE copy 0
x
1
diff --git a/eo-runtime/src/test/eo/org/eolang/goto-tests.eo b/eo-runtime/src/test/eo/org/eolang/goto-tests.eo
index 4c22b157ce..f215340849 100644
--- a/eo-runtime/src/test/eo/org/eolang/goto-tests.eo
+++ b/eo-runtime/src/test/eo/org/eolang/goto-tests.eo
@@ -45,7 +45,7 @@
seq > @
*
i.write (i.as-int.plus 1)
- if.
+ if
i.as-int.lt 10
g.backward
TRUE
@@ -65,7 +65,7 @@
seq > @
*
i.write (i.as-int.plus 1)
- if.
+ if
i.as-int.lt 10
g.backward
TRUE
@@ -87,7 +87,7 @@
[g]
seq > @
*
- if.
+ if
x.eq 0
g.forward TRUE
TRUE
@@ -111,7 +111,7 @@
[g]
seq > @
*
- if.
+ if
a.gt b
g.forward a
TRUE
diff --git a/eo-runtime/src/test/eo/org/eolang/unit-tests.eo b/eo-runtime/src/test/eo/org/eolang/if-tests.eo
similarity index 88%
rename from eo-runtime/src/test/eo/org/eolang/unit-tests.eo
rename to eo-runtime/src/test/eo/org/eolang/if-tests.eo
index 552f98353a..bf32b1e6e2 100644
--- a/eo-runtime/src/test/eo/org/eolang/unit-tests.eo
+++ b/eo-runtime/src/test/eo/org/eolang/if-tests.eo
@@ -27,12 +27,19 @@
+version 0.0.0
# Test.
-[] > x
- TRUE > @
+[] > forks-on-true-condition
+ eq. > @
+ if
+ 5.eq 5
+ 123
+ 42
+ 123
# Test.
-[] > z
- # Y.
- [x] > y
- x > @
- TRUE > @
+[] > forks-on-false-condition
+ eq. > @
+ if
+ 5.eq 8
+ 123
+ 42
+ 42
\ No newline at end of file
diff --git a/eo-runtime/src/test/eo/org/eolang/int-tests.eo b/eo-runtime/src/test/eo/org/eolang/int-tests.eo
index 25a16a6033..b0bd672358 100644
--- a/eo-runtime/src/test/eo/org/eolang/int-tests.eo
+++ b/eo-runtime/src/test/eo/org/eolang/int-tests.eo
@@ -187,7 +187,7 @@
[] > calculates-fibonacci-number-with-recursion
# Fibonacci.
[n] > fibo
- if. > @
+ if > @
n.lt 3
1
plus.
@@ -205,21 +205,21 @@
# Fibonacci.
[n] > fibonacci
- if. > @
+ if > @
n.lt 3
small n
rec n 1 1
# Small.
[n] > small
- if. > @
+ if > @
n.eq 2
1
n
# Recursive.
[n minus1 minus2] > rec
- if. > @
+ if > @
n.eq 3
minus1.plus minus2
rec (n.minus 1) (minus1.plus minus2) minus1
diff --git a/eo-runtime/src/test/eo/org/eolang/runtime-tests.eo b/eo-runtime/src/test/eo/org/eolang/runtime-tests.eo
index 52522ed241..1676fa03cd 100644
--- a/eo-runtime/src/test/eo/org/eolang/runtime-tests.eo
+++ b/eo-runtime/src/test/eo/org/eolang/runtime-tests.eo
@@ -94,7 +94,7 @@
0
# X.
[i] > x
- if. > @
+ if > @
i.lt 0
0
x
@@ -185,7 +185,7 @@
memory 0 > n
# Func.
[] > func
- if. > @
+ if > @
n.as-int.gt 0
seq
*
diff --git a/eo-runtime/src/test/java/EOorg/EOeolang/EOerrorTest.java b/eo-runtime/src/test/java/EOorg/EOeolang/EOerrorTest.java
index 6da003c34f..5441c74e20 100644
--- a/eo-runtime/src/test/java/EOorg/EOeolang/EOerrorTest.java
+++ b/eo-runtime/src/test/java/EOorg/EOeolang/EOerrorTest.java
@@ -59,7 +59,7 @@ void makesToxicObject() {
() -> new Dataized(
new PhWith(
new EOerror(Phi.Φ),
- "α",
+ "message",
new Data.ToPhi("intentional error")
)
).take()
@@ -116,7 +116,7 @@ private static final class MyError extends PhDefault {
new PhCopy(
Phi.Φ.attr("org").get().attr("eolang").get().attr("error").get()
),
- "α",
+ "message",
new Data.ToPhi(data)
)
)
diff --git a/eo-runtime/src/test/resources/org/eolang/snippets/all.yaml b/eo-runtime/src/test/resources/org/eolang/snippets/all.yaml
index c2fc78f26c..7d2d1e534f 100644
--- a/eo-runtime/src/test/resources/org/eolang/snippets/all.yaml
+++ b/eo-runtime/src/test/resources/org/eolang/snippets/all.yaml
@@ -12,7 +12,7 @@ eo: |
42
# This is the default 64+ symbols comment in front of named abstract object.
[x] > foo
- if. > @
+ if > @
x.eq 0
error "x is zero"
42
diff --git a/eo-runtime/src/test/resources/org/eolang/snippets/fibo.yaml b/eo-runtime/src/test/resources/org/eolang/snippets/fibo.yaml
index 846ca25987..4d0814c773 100644
--- a/eo-runtime/src/test/resources/org/eolang/snippets/fibo.yaml
+++ b/eo-runtime/src/test/resources/org/eolang/snippets/fibo.yaml
@@ -11,7 +11,7 @@ eo: |
[args] > fibo
# This is the default 64+ symbols comment in front of named abstract object.
[n] > f
- if. > @
+ if > @
n.lt 2
n
plus.
diff --git a/eo-runtime/src/test/resources/org/eolang/snippets/ifthenelse.yaml b/eo-runtime/src/test/resources/org/eolang/snippets/ifthenelse.yaml
index af2177dab8..975e541ab1 100644
--- a/eo-runtime/src/test/resources/org/eolang/snippets/ifthenelse.yaml
+++ b/eo-runtime/src/test/resources/org/eolang/snippets/ifthenelse.yaml
@@ -10,7 +10,7 @@ eo: |
[args] > ifthenelse
# This is the default 64+ symbols comment in front of named abstract object.
[n] > f
- if. > @
+ if > @
n.lt 0
"smaller"
"greater"
diff --git a/eo-runtime/src/test/resources/org/eolang/snippets/vertical-binded-methods.yaml b/eo-runtime/src/test/resources/org/eolang/snippets/vertical-binded-methods.yaml
index c2a1739af0..59b9ef07d5 100644
--- a/eo-runtime/src/test/resources/org/eolang/snippets/vertical-binded-methods.yaml
+++ b/eo-runtime/src/test/resources/org/eolang/snippets/vertical-binded-methods.yaml
@@ -9,9 +9,9 @@ eo: |
# This is the default 64+ symbols comment in front of named abstract object.
[args] > vbm
stdout > @
- if.
- TRUE
- "second":1
+ if
+ "second":2
+ TRUE:0
"first"
.as-bytes
- .as-string:0
+ .as-string:1