Eric Brine <ikegami <at> adaelis.com> writes: >>where {} is currently parsed as a hash constructor but that >>gives a syntax error, perl should try instead to parse it as a block. >Perl uses an LR parser and resolves these conflicts by looking ahead. > >"{" is determined to be a hash constructor by looking ahead and seeing "}". >It would have to look even ahead further to determine a syntax error follows Hmm, I see. Suppose for the moment that making the parser backtrack is not practical. Would there be some new heuristic that could be used instead? For example, suppose you declare that the empty anonymous hash {} can never appear in an lvalue position. Might that work? At the moment you get % perl -E '{} ++' Can't modify anonymous hash ({}) in postincrement (++) but with the changed heuristics, {} would never even get as far as being parsed as an lvalue for the ++ operator to apply to it, so you'd instead see a plain 'syntax error'. -- Ed Avis <eda@waniasset.com>Thread Previous | Thread Next