For p6, they already moved one step ahead with separation of $thing x $count being a scalar-repeat(*) and $thing xx $count being a list-repeat(*).
* My terms, probably incorrect.
Looking at the output from -MO=concise for various uses of x, it looks like the optree has enough information in it to allow the repeat operator (or maybe the peep-hole optimiser) to determine whether the list being repeated contains a single 'active' element. Where 'active' is basically anything that isn't a constant or simple scalar: an srefgen; a function call etc. and have a special case for calling that active element iterator wise. The problem is it would the require some way to indicate when you really did want the list-wise replication of a single actively generated list item, and would break all existing uses.
So, I guess the question is: Is there any syntactically nice way of indicating the difference between my @data = rand xx 1000; meaning I want a thousand different random numbers and my @data = rand xx 1000; I want a thousand copies of the same random number.
I toyed with my @data = rand xxx 1000; for the former, but that would probably get every site displaying perl code using it blocked under "18 USC 2257", which might not be a good idea :)
Another possibility is that my @a = { ... } xx 1000; would call the anon. block (or subref) 1000 times, but whether that is sufficiently clearer than my @a = map{ ... } 1 .. 1000; to be worth the cruft is the kind of decision that LW gets right whilst the rest of us are still uming annd ahhing.
In reply to Re^3: Using x to build data structures considered harmful
by BrowserUk
in thread Using x to build data structures considered harmful
by dws
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |