On Aug 1, 2012, at 8:05 AM, Father Chrysostomos via RT wrote: > On Tue Jul 31 08:55:25 2012, sprout wrote: >> $ ./perl -Ilib -Mwarnings=syntax -e '@a[]' >> Scalar value @a[] better written as $a[] at -e line 1. >> syntax error at -e line 1, near "[]" >> Execution of -e aborted due to compilation errors. >> >> We could change it to skip the warning for the empty string or an >> initial alphanumeric character. Instead of warning immediately, the >> lexer could flag the op, and the compiler could then look to see whether >> there is indeed just one kidop and warn. >> >> I think that would work, without making the lexer’s heuristics overly >> complex. >> >> Is there anything obviously wrong with that? > Yes: the source code cannot easily be accessed once one has an op. > > Would it be acceptable to change the warning to use an ellipsis? > (Scalar value @a[...] better written as $a[...].) > > Would it be acceptable to remove this warning altogether? The only case > that could cause a problem is @a[+foo], because foo could be called > unexpectedly in list context. But that is precisely the case in which > perl cannot know that foo won’t return a list on purpose. @a[0] is > generally harmless. Is this supposed to be newbie patrol (to stop them > from using @a[0] all over the place)? I wonder whether this warning shouldn't be removed on the grounds that: 1. it is valid Perl 6 syntax, so what are we teaching newbies anyway? 2. there is only a performance difference between $a[0] and @a[0], or am I missing something there? LizThread Previous | Thread Next