Recently on perlmonks, at http://perlmonks.org/index.pl?node_id=375255,
someone (DWS, actually) brought up the common error of expecting x (in
particular, listy x, which is xx in perl6) to not create aliases. What
he was doing in particular, I don't have any expectation of making it
work, but what about the also-common problem of C< @randoms = (int rand
100) xx 100 >? In perl5, this picks one random integer between 0 and
99, and copies it 100 times -- not what was intended. The best way to
do this is C< my @randoms = map {int rand 100} 0..100; >, which is
rather yucky -- conceptually, you aren't trying to transform one list
into another. OTOH, C< my @randoms; push @randoms, int rand 100 for
0..100 > is even yuckier.
Perhaps if the LHS of a xx operator is a closure, it should run the
closure each time around... or perhaps there should be an xxx operator.
(Both suggestions from BrowserUk's reply,
http://perlmonks.org/index.pl?node_id=375344). The former raises the
question of what you do if you really want to repeat a coderef, and the
later raises the possibly of being blocked (really), and starts to
become confusing -- the difference between x and xx is sensical -- the
former repeats one thing, the later many... but what's the reasoning for
xxx, other then that it's like xx? How will users be able to remember
which is which?
-=- James Mastros,
theorbtwo