On Mon, Oct 20, 2014 at 11:11:22PM -0000, Father Chrysostomos wrote:
Yves Orton wrote:
Nothing, as far as I can tell. (But nothing says that % should not
evaluate its right operand three times.)
ity concerns, are sufficient reason to keep it that way.
If we skipped evaluating the left-hand side for 0 on the right, then
we would have to change the evaluation order of (foo()) x bar() as
well, if we want it to be predictable whether foo() is called.
not worth it.I'm beginning to lean in the opposited direction. I often use similar
constructs. And my only reason for avoiding them when I do is effi-
ciency, which suggests that perl ought to be worrying about effi-
ciency for me.
Yves Orton wrote:
On 20 October 2014 21:34, Father Chrysostomos <sprout cpan.org> wrote:
(foo())x256 should call foo() exactly once, as
should (foo())x0.
Forgive me for asking, but what says it should?(foo())x256 should call foo() exactly once, as
should (foo())x0.
evaluate its right operand three times.)
(This is aside from the
fact that what you say is a reasonable expectation.)
The fact that it is a reasonable expectation, and backward-compatibil-fact that what you say is a reasonable expectation.)
ity concerns, are sufficient reason to keep it that way.
If we skipped evaluating the left-hand side for 0 on the right, then
we would have to change the evaluation order of (foo()) x bar() as
well, if we want it to be predictable whether foo() is called.
We could conceivably optimise ("constant")x0 and ($foo)x0 and any
other op known not to have any observable side effects. But is
it worth it? (Oh no, I'm probably going to end up doing it! :-)
Aside from me being curious where this is specified, I think its probablyother op known not to have any observable side effects. But is
it worth it? (Oh no, I'm probably going to end up doing it! :-)
not worth it.
constructs. And my only reason for avoiding them when I do is effi-
ciency, which suggests that perl ought to be worrying about effi-
ciency for me.
- presently, both the LHS and RHS of expr1 x expr2 are evaluated, always.
- and the LHS is evaluated first, then the RHS.
- if any of the above could change, the possible things are:
1. change the order to evaluate the RHS first,
2. do not evaluate the LHS if the RHS is numerically zero (requires #1).