> > > @arr3 = @arr1[^i] + @arr2[^i] # also @arr[^i] = @arr1[^i] + @arr2[^i] > > Hyper-operators do this just fine. >
Oh yes they do. The point is that the ^i-loop way is better (more powerful and simpler at the same time). Maybe the examples where not good enough. Take the @b ^/ $a expression. You cannot be sure about what it does until you know the types of the variables, and this can be not obvious: $a = (1,2,3); @b = (2,4,6); $c = 2; print @b ^/ $c; #-> 1 2 3 print @b ^/ $a; #-> 2 2 2 In this example the last two lines look exactly the same, but what they do is quite different. Perl whould do what i mean in both cases, but it's quite probable that i don't actually know what i mean in the second one. :( On the other hand: print @b[^i] / $c; print @b[^i] / $a[^i]; Is much more clear in the sense that is more explicit. I like explicitness, it makes me fell safe. That's good. Really. And you can do operations that are simply not possible with the hyperoperator operator: print @b[^i] * $a[^j] # -> 2 1 6 4 8 12 6 12 18 # There are much better examples than this one, but it's the first one # it came to my mind. See the RFC for a bunch of much better ones. Another example, maybe more important. Imagine you have a good old LOL matrix: my @matrix = ( ["have", "a"], ["nice", "day" ] ); $b = @matrix^length();# abusing ^ sintax, i guess this will be # somehow possible. It is imho # suggested by A3, but it is not said anywhere, so # maybe it simply cannot be done $b can be a list of the nested lists' length or a matrix of the scalars' length. It would probably DWIM for some definition of DWIM-ness, but ¿which one?? I don't know, and if i were a new user (even if i had used hyperoperators before) I should have to read the docs and probably write a sample program to find out. But: $b = @matrix[^i,^j].length() #-> ([4,1],[4,3]) and $b = @matrix[^i].length() #-> (2, 2) Are both clear as water. You would never ask what is difference between them. > > These can be done in Perl 5 easily enough with map or foreach: > > @arr4 = map {$v * $_} @arr1 > $sum += $_ foreach (@arr1) > @lengths_array = map { length } @arr1 > > [...] > > I don't *dislike* the idea, I'm just pointing out that there's a lot > of it already in the language. Perhaps making map/foreach/grep more > flexible with some kind of adverbial modification would be more > effective (e.g. having a way to specify an incrementor variable or > the temporary variable for map would allow nested maps to be more > useful). > I understand what you say, but I still believe that the array loop is: * a more explicit (and thus safer) replacement for hyperoperators * a _much_ more general and powerful solution * a smaller adittion to the language # this one could be argable * more expressive than map/grep/foreach So what I try to say is that i believe that ^i-loops (or maybe hyperloops ;-) would be a important addition to Perl, and that in case they were accepted, the whole hyperoperators family becomes redundant. By the way, I am not the autor of the idea. I just found the RFC very interesting on the first time, and it came back to me after reading the A3. On the other hand, I find your proposal of enhancing of map/foreach/grep using adverbs very interesting. Could you please provide some examples? --- Angel Faus [EMAIL PROTECTED]
""
Description:
""
Description:
""
Description:
""
Description:
""
Description:
""
Description: