On Wed, Nov 23, 2005 at 08:04:32AM -0800, Peter Scott wrote: : On Tue, 22 Nov 2005 14:34:12 -0800, Larry Wall wrote: : > What tipped me over the edge, however, is that I want ^$x back for a unary : > operator that is short for 0..^$x, that is, the range from 0 to $x - 1. I : > kept wanting such an operator in revising S09. It also makes it easy to : > write : > : > for ^5 { say } # 0, 1, 2, 3, 4 : : It seems strange to have a shortcut for 0..$n-1 but no shortcut for 0..$n.
But then you'd usually want 1..$n instead... : I'm also puzzled that you feel the need to write 0..$n-1 so often; there : are so many alternatives to fenceposting in P5 that I almost never write : an expression like that, so why is it cropping up that much in P6? Couple reasons occur to me offhand. First we're doing away with $#foo. Second is all the array sizing in P5 is implicit, whereas S9 style arrays are all about explicit array sizing, and 0..$n-1 comes up all the time there. But I also am liking the generalization of unary ^ to mean domain. And in an axiomatic sort of way, it corresponds to those theories of math that build up the integers by counting set elements. The "argument" that produces 5 is 0..4. And it works out that +^5 == 5. But the generalization to hashes is even cooler because I can say my %thishash{^%thathash}; or some such to duplicate the "shape" regardless of the typology of %thathash. Larry