On Sun, Oct 19, 2014 at 10:55:17PM +0200, Aristotle Pagaltzis wrote:
Amusingly, there is one serious drawback of this idiom that no ever
seems to pick on when they object to it. (Maybe because their eyes are
drawn to the more immediately obvious apparent problems so that they
don’t get far enough to notice?) Namely, *unlike the ternary*, the
repeat operator does not short-circuit, and so the list expression on
the left side is always evaluated. If that expression is costly to
compute, the repeat operator is a bad choice. If said expression has
side effects, it is probably a bug outright to prefer the repeat over
the ternary. (It would actually make sense to me to change that about
the repeat operator, but I suspect that ship has sailed long ago.) But,
in this particular case, the list expression is just a constant, so that
concern does not apply.
Indeed, yes -- one might expect that if the repeat operator was a
compile-time constant and numified to zero, that the LHS should not be
evaluated at all.

How hard would it be to change this in the parser and see what would be
affected by the change? Is it worth it?

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 11 of 34 | next ›
Discussion Overview
groupperl5-porters @
postedOct 19, '14 at 2:29a
activeOct 25, '14 at 9:51a



site design / logo © 2021 Grokbase