# New Ticket Created by  Zefram 
# Please include the string:  [perl #129013]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=129013 >


> ((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

Reply via email to