Commit e6cea5ab
e6cea5abecd5Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified
Description
Document grapheme_clusters and flip-flop as unsupported
Spinel deliberately does not carry a Unicode grapheme-break table, so String#grapheme_clusters / #each_grapheme_cluster are out of scope. The flip-flop operator is rarely used and carries hidden per-site state; a program using it fails to compile rather than running wrong. Record both in docs/INCOMPATIBILITIES.md.
Refs #1284, #1287
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- e6cea5abecd5
- Parent
- 4c803fb1d7c0
docs/INCOMPATIBILITIES.mdmodifiedView file
@@ -38,3 +38,39 @@
3838
```ruby3939
2.0 ** -1 # => 0.54040
```41+
42+
## `String#grapheme_clusters`43+
44+
CRuby splits a string into Unicode extended grapheme clusters:45+
46+
```ruby47+
"á".grapheme_clusters # => ["á"] (one cluster: a + combining accent)48+
```49+
50+
Correct grapheme segmentation requires shipping and maintaining the Unicode51+
grapheme-break property tables, which Spinel deliberately does not carry.52+
`String#grapheme_clusters` and `String#each_grapheme_cluster` are therefore not53+
supported. For codepoint- or byte-level iteration, use the supported54+
`String#chars`, `#each_char`, `#codepoints`, or `#bytes`.55+
56+
## Flip-flop operator57+
58+
CRuby supports the flip-flop operator (a `Range` used as a condition, toggled59+
between its two endpoints):60+
61+
```ruby62+
(1..10).each { |i| puts i if (i == 3)..(i == 5) } # prints 3, 4, 563+
```64+
65+
This is a rarely used feature with surprising hidden per-site state, and Spinel66+
does not support it; a program using it fails to compile rather than running67+
with wrong behavior. Use an explicit boolean state variable instead:68+
69+
```ruby70+
active = false71+
(1..10).each do |i|72+
active = true if i == 373+
puts i if active74+
active = false if i == 575+
end76+
```