Skip Menu |
Report information
Id: 129013
Status: new
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: zefram [at]

Severity: (no value)
Tag: Bug
Platform: (no value)
Patch Status: (no value)
VM: (no value)

From: Zefram <zefram [...]>
To: rakudobug [...]
Subject: [BUG] Range.perl and Pair.perl precedence disagreement
Date: Sat, 20 Aug 2016 10:11:11 +0100
Download (untitled) / with headers
text/plain 1.2k
Show quoted text
> ((3 => 3) .. (4 => 4)).WHAT
(Range) Show quoted text
> ((3 => 3) .. (4 => 4)).perl.EVAL.WHAT
(Pair) Show quoted text
> ((3 => 3) .. (4 => 4)).perl
3 => 3..4 => 4 Show quoted text
> ((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

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at