S03 says:

   Increment of a Str (in a suitable container) works similarly 
   to Perl 5 except that the final alphanumeric sequence in the 
   string is incremented regardless of what comes before it.

What does "final alphanumeric sequence" really mean here?
Perl 5 does magic autoincrementing of non-empty strings that match
the (perl5) pattern  /^[A-Za-z]*[0-9]*\z/ .  Does it continue to
have a Perl 5'ish interpretation -- i.e., alphas followed by
digits (non-empty match of /[A-Za-z]*[0-9]\z/), or is it really 
any alphanumeric sequence ( /[A-Za-z0-9]+\z/ ) ?  And, of course,
what about Unicode?

The choices make for different results -- consider incrementing

    Original      /[A-Za-z]*[0-9]*\z/       /[A-Za-z0-9]*\z/
    '123zzz'         '123aaaa'                 '124aaa'
    '4z99'           '4aa00'                   '5a00'

Any clues here?

I'm also assuming that a string that doesn't have a final
alphanumeric sequence ends up performing a numeric increment,
as Perl 5 does.

For completeness:  Strings that matched the Perl 5 pattern
do continue to work the same (under either interpretation of
"final alphanumeric sequence"):

    '12'  becomes '13'
    '99'          '100'
    'a0'          'a1'
    'aa'          'ab'
    'az'          'ba'
    'Aa'          'Ab'
    'Az'          'ba'
    'zz'          'aaa'
    'Zz'          'AAz'

Allowing magic autoincrement to work on any final alphanumeric
sequence also means that we get things like:

    '123Any' becomes '123Anz'
    '@34'            '@35'
    '@99'            '@100'
    'x.54'           'x.55'
    'x.99'           'x.100'
    '0.27'           '0.28'
    '0.99'           '0.100'    # not '1.00'
    '0x99'           '0y00'     # not '0x9a' or '0x100' 
    '0d99'           '0e00'

Any comments or suggestions for interpreting S03 here are
greatly appreciated.  :-)  If this gets into detailed
design issues, we may need to move the subject to
perl6-language for interpretation.

And, of course, tests for the above are welcome.  Currently
there are some tests for string autoincrement in t/operators/auto.t
(there may be others I haven't found yet).

Thanks!

Pm

Reply via email to