You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.markdown
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,9 @@ All notable changes to this project will be documented in this file.
4
4
5
5
The format is based on [Keep a Changelog](https://keepachangelog.com/), and this project now adheres to [Semantic Versioning](https://semver.org/).
6
6
7
-
## 3.11.0 - Unreleased
7
+
## 3.11.0 - 2025-12-25
8
+
9
+
Note: the new features in this release bring about [changes to the best practices](doc/syntax/BEST-PRACTICES.markdown#mindcode-311) for writing Mindcode.
Copy file name to clipboardExpand all lines: doc/syntax/BEST-PRACTICES.markdown
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ The most important change in the 3.11 release comes with the ability to short-ci
21
21
> y = a > 0 or b > 0 ? 1: -1;
22
22
> ```
23
23
>
24
-
> would evaluate the condition `a > 0 or b > 0` only once, reusing it in the second statement. This is no longer the case with short-circuited conditions; for cases like this, replace the condition with a single `if` statement:
24
+
> would evaluate the condition `a > 0 or b > 0` only once, reusing it in the second statement. This is no longer the case with short-circuited conditions; in similar situations, use a single `if` statement instead:
25
25
>
26
26
> ```Mindcode
27
27
> if a > 0 or b > 0 then
@@ -74,7 +74,7 @@ Mindcode provides an [option](SYNTAX-5-OTHER.markdown#option-symbolic-labels) fo
74
74
75
75
# The `case` expressions
76
76
77
-
Mindcode provides a very powerful optimization for `case` expressions, in case where all the `when` values are either integer constants, or constant Mindustry objects of the same type (blocks, items, etc.)
77
+
Mindcode provides a very powerful optimization for `case` expressions, in case where all the `when` values are either integer constants, or constant Mindustry objects of the same type (blocks, items, etc.).
78
78
79
79
As an extreme example, in target `8.0` or higher Mindcode may be capable of converting the entire case expression into a single instruction:
80
80
@@ -95,7 +95,7 @@ read .output "ABC" :input
95
95
96
96
The following measures may help produce the most efficient code:
97
97
98
-
* When using Mindustry objects as `when` values, set the [`builtin-evaluation` option](SYNTAX-5-OTHER.markdown#option-builtin-evaluation) to `full`. This means the compiler only considers the Mindustry objects which exist in the given target and doesn't need to produce code for handling unknown objects.
98
+
* When using Mindustry objects as `when` values, set the [`builtin-evaluation` option](SYNTAX-5-OTHER.markdown#option-builtin-evaluation) to `full`. This means the compiler only considers the Mindustry objects which exist in the given target and doesn't need to produce code for handling unknown objects. On the other hand, the compiled code is only guaranteed to run correctly on Mindustry versions compatible with the chosen target. Consider using the [`target-guard` option](SYNTAX-5-OTHER.markdown#option-target-guard) to ensure the program won't run on incompatible Mindustry versions.
99
99
* If possible, use printable characters as `when` values. For example, if your case expression produces a few categories, consider assigning each category a value using character literals (e.g. `'A'`, `'B'` or `'0'`, `'1'` and so on). If you need to perform additional computations on the resulting values, though, use the natural values in the `when` clause and let Mindcode perform the necessary conversions.
100
100
101
101
An `in` operator applied to a list of values uses `case`expression internally, so it benefits from the same optimizations.
0 commit comments