Skip to content

Commit 065a718

Browse files
committed
clarify that range->seq translation implies *.succ
1 parent 521e009 commit 065a718

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

S03-operators.pod

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -509,16 +509,27 @@ predecessors, and will fail if you run off of either end.
509509
❶..❿ # dingbat negative circled 1..10
510510
etc.
511511

512+
Note: for actual ranges in Perl you'll need to quote the characters above:
513+
514+
'⓪'..'㊿' # circled digits/numbers 0..50
515+
512516
If you want to future-proof the top end of your range against further
513517
Unicode additions, you may specify it as "whatever":
514518

515-
⓪..* # circled digits/numbers up to current known Unicode max
519+
'⓪'..* # circled digits/numbers up to current known Unicode max
520+
521+
Since these non-carrying ranges fail when they run out, it is
522+
recommended that you avoid non-carrying rangechars where, for instance,
523+
you need to keep generating unique filenames. It's much better to
524+
generate longer strings via carrying rangechars in such cases.
525+
526+
Note that all character increments can be handled by lookup in a
527+
single table of successors since we've defined our ranges not to overlap.
516528

517-
(Note that we can't just increment unrecognized characters, because
529+
Anyway, back to string increment. Only rangechars may be incremented;
530+
we can't just increment unrecognized characters, because
518531
we have to locate the string's final sequence of rangechars before knowing
519-
which portion of the string to increment. Note also that all character
520-
increments can be handled by lookup in a single table of successors
521-
since we've defined our ranges not to include overlapping cycles.)
532+
which portion of the string to increment.
522533

523534
Perl 6 also supports C<Str> decrement with similar semantics, simply by
524535
running the cycles the other direction. However, leftmost characters
@@ -2057,6 +2068,16 @@ Hence, to produce all octal numbers that fit in 16 bits, you can say:
20572068

20582069
'000000' ... '177777'
20592070

2071+
At need, you can override these numeric codepoint semantics by using
2072+
an explicit successor function:
2073+
2074+
'⓪', *.succ ... '㊿' # circled digits/numbers 0..50
2075+
2076+
(In fact, this is precisly what the translation from ranges does, in
2077+
order to preserve the abstract ordering of rangechars that have
2078+
non-contiguous codepoints. But it's easier just to use the range
2079+
operator if that's the case.)
2080+
20602081
If the start string is shorter than the stop string, the strings are
20612082
assumed to be right justified, and the leftmost start character is
20622083
duplicated when there is a carry:

0 commit comments

Comments
 (0)