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 ```ruby
3939 2.0 ** -1 # => 0.5
4040 ```
41+
42+## `String#grapheme_clusters`
43+
44+CRuby splits a string into Unicode extended grapheme clusters:
45+
46+```ruby
47+"á".grapheme_clusters # => ["á"] (one cluster: a + combining accent)
48+```
49+
50+Correct grapheme segmentation requires shipping and maintaining the Unicode
51+grapheme-break property tables, which Spinel deliberately does not carry.
52+`String#grapheme_clusters` and `String#each_grapheme_cluster` are therefore not
53+supported. For codepoint- or byte-level iteration, use the supported
54+`String#chars`, `#each_char`, `#codepoints`, or `#bytes`.
55+
56+## Flip-flop operator
57+
58+CRuby supports the flip-flop operator (a `Range` used as a condition, toggled
59+between its two endpoints):
60+
61+```ruby
62+(1..10).each { |i| puts i if (i == 3)..(i == 5) } # prints 3, 4, 5
63+```
64+
65+This is a rarely used feature with surprising hidden per-site state, and Spinel
66+does not support it; a program using it fails to compile rather than running
67+with wrong behavior. Use an explicit boolean state variable instead:
68+
69+```ruby
70+active = false
71+(1..10).each do |i|
72+ active = true if i == 3
73+ puts i if active
74+ active = false if i == 5
75+end
76+```