On 11/23/05, Larry Wall <[EMAIL PROTECTED]> wrote: > : 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.
What about @array.indices instead? Then, there's no possible fenceposting, your code is self-documenting, and we're not introducing another unary operator? > 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. So, +^5 is the way to generate the Church number for 5 through the use of an iterator masquerading as a range? > 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. my %thishash{%thathash.keys}; Much easier to read. The methods are there for a reason. Don't re-add operators where there's a perfectly good method. Plus, overwriting methods is much easier to grok for the average programmer than the corresponding operator, unless you're aliasing the operator, in which case I have problems figuring out why this is good, unless we're deliberately designing P6 for the obfu/golf crowd.