Re: RFC 82 (v3) Arrays: Apply operators element-wise in a list context
[email protected] Sat, 09 Sep 2000 15:58:41 +1200
| Newsgroups | perl.perl6.language.data |
|---|---|
| Organization | University of Auckland |
| Message-ID | <[email protected]> |
Nathan Wiger wrote: > > > This RFC proposes that operators in a list context should be applied > > element-wise to the elements of their arguments: > > > > @d = @b * @c; # Returns (2,8,18) > > > > If the lists are not of equal length, an error is raised. > > I've been watching this RFC for a while. I would hesitate to change the > default behavior of * and other operators in so radical a sense, > especially since it would create unexpected error conditions. I think > these operations should remain scalar. I disagree. You end up with a situation where some @a * @b; are in scalar context, some not. And what happens when you say @a = (1,2,2); @b = tie Matrix (1,2,3); @a*@b; Who wins? From the user point of view a 1D multi-dim array will look just the same as a normal perl list in *all* respects in a would-be perl6. I bet money that users will be highly confused if some arrays enforce scalar context in such operations, others don't. It is *much* clearer to have a clear break with perl5 in this respect (even if code needs to be rewritten). A p52p6 could replace all occurences of @a*@b with scalar(@a)*scalar(@b). Christian