On Sun, Jan 29, 2017 at 02:27:31AM +0000, Zefram wrote: > Where a single item is being lexicalised, as in "my $x", the item is > syntactically required to be a scalar, array, or hash. Thus "my &z" > is rejected early on. But where a parenthesised list of items is being > lexicalised, the syntax permits the parens to contain any expression > whatsoever. The restriction on what can be lexicalised is instead > implemented by walking the optree of the completed list, checking that > it semantically only contains acceptable items. Hence this difference > in diagnostics: > > $ ./perl -le 'my &z' > syntax error at -e line 1, near "my &z" > Execution of -e aborted due to compilation errors. > $ ./perl -le 'my(&z)' > Can't declare subroutine entry in "my" at -e line 1, at EOF > Execution of -e aborted due to compilation errors. Is there any reason why a my() list can't be enforced (in a strict manner) by the lexer / grammar itself rather than post-hoc by optree inspection? -- "Foul and greedy Dwarf - you have eaten the last candle." -- "Hordes of the Things", BBC Radio.Thread Previous | Thread Next