summaryrefslogtreecommitdiff
path: root/chapter23
diff options
context:
space:
mode:
Diffstat (limited to 'chapter23')
-rw-r--r--chapter23/README.ja.md2
-rw-r--r--chapter23/README.md14
2 files changed, 14 insertions, 2 deletions
diff --git a/chapter23/README.ja.md b/chapter23/README.ja.md
index 40fa09db..363b3de4 100644
--- a/chapter23/README.ja.md
+++ b/chapter23/README.ja.md
@@ -5,7 +5,7 @@
この文書は [原文](README.md) の日本語訳です。
[前の章: 第22章](../chapter22/README.ja.md) |
-[次の章: 第24章](../chapter24/README.ja.md)
+[次の章: 第24章](../chapter24a/README.ja.md)
この章では *メソッド* を追加します。構造体内で定義し、隠れた `self` 引数を取り、構造体のフィールドへアクセスできる関数です。文字列のようなクラスの `indexOf` メソッドを示します。
diff --git a/chapter23/README.md b/chapter23/README.md
index c99d2441..8f371e9b 100644
--- a/chapter23/README.md
+++ b/chapter23/README.md
@@ -3,7 +3,7 @@
English | [日本語](README.ja.md)
[Previous: Chapter 22](../chapter22/README.md) |
-[Next: Chapter 24](../chapter24/README.md)
+[Next: Chapter 24a](../chapter24a/README.md)
In this chapter we add *methods*, functions defined in structs which take a
hidden `self` argument and can access the struct fields. Here is an
@@ -53,6 +53,18 @@ You can also read [this chapter](https://github.com/SeaOfNodes/Simple/tree/linea
Here is the [complete language grammar](docs/23-grammar.md) for this chapter.
+## Chained comparisons
+
+`lo <= x < hi` compares adjacent values and evaluates `x` only once. If the
+first comparison fails, the later operand is not evaluated. This uses the
+same control and scope merges as short-circuit expressions; it does not need
+SCCP. For example, `10 < 30 < 20` is false, and `0 < 2 <= 2` is true.
+
+A chain must keep one direction, but may mix strict and inclusive tests:
+`a < b <= c` and `a >= b > c` are allowed; `a < b > c` is rejected. Equality
+has lower precedence and does not join a chain. Parentheses can still make
+the result of one comparison an operand of another.
+
## Why Cyclic Types?
Cyclic types give us a sharper analysis than the alternative, and thus admit