Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Range.perl and Pair.perl precedence disagreement #5601

Open
p6rt opened this issue Aug 20, 2016 · 1 comment
Open

Range.perl and Pair.perl precedence disagreement #5601

p6rt opened this issue Aug 20, 2016 · 1 comment
Labels

Comments

@p6rt
Copy link

p6rt commented Aug 20, 2016

Migrated from rt.perl.org#129013 (status was 'new')

Searchable as RT129013$

@p6rt
Copy link
Author

p6rt commented Aug 20, 2016

From zefram@fysh.org

((3 => 3) .. (4 => 4)).WHAT
(Range)
((3 => 3) .. (4 => 4)).perl.EVAL.WHAT
(Pair)
((3 => 3) .. (4 => 4)).perl
3 => 3..4 => 4
((3 => 3) .. (4 => 4)).perl.EVAL.perl
3 => (3..4) => 4

Failure of .perl.EVAL round-tripping. Range.perl is assuming that the
.perl of its endpoints will have higher precedence than what Pair.perl
actually provides. One or other of them needs to parenthesise the Pair
expression to be embedded in the Range expression.

Bigger picture​: for .perl methods to work together, there needs to be
agreement on precedence and other features of the expression returned by
.perl. It needs to be clear whose responsibility it is to parenthesise
expressions in each case. Currently the documentation doesn't say
anything about this. It ought to specify some precedence level that
the expression will satisfy. Any .perl generating a looser expression
needs to parenthesise its output; any .perl requiring a tighter operand
expression needs to parenthesise the .perl that it gets from its operand.
Some unfortunate cases will get double parenthesisation or unnecessary
single parenthesisation; this can be minimised by careful selection of
the API precedence level. (To avoid unnecessary parenthesisation entirely
would require explicitly signalling the precedence of each expression.)

-zefram

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant