Hi,

S05 describes an array version of trans for transliteration:
 ( http://dev.perl.org/perl6/doc/design/syn/S05.html#Transliteration )

  The array version can map one-or-more characters to one-or-more characters:

     $str.=trans( [' ',      '<',    '>',    '&'    ] =>
                  ['&nbsp;', '&lt;', '&gt;', '&amp;' ]);

  In the case that more than one sequence of input characters matches,
  the longest one wins. In the case of two identical sequences the first
  in order wins.

Why does the longest input sequence win? Is it for some consistency that that I'm not seeing? Some exceedingly
common use case?  The rule seems unnecessarily restrictive.

The "first in order" rule is more flexible, the user can sort their
arrays to produce the longest input rule, or use another order if that is
preferred.  The first transliteration example even uses sort in
the pair-wise form:

  $str.trans( %mapping.pairs.sort );

Can we drop the longest preference?

Brad

--
 By inconsistency and frivolity we stray from the Way and show ourselves
 to be beginners. In this we do much harm.
                                    -- Hagakure http://bereft.net/hagakure/

Reply via email to