Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re^8: ref to read-only alias ... why? (eval)

by LanX (Bishop)
on Jan 09, 2012 at 21:46 UTC ( #947073=note: print w/replies, xml ) Need Help??

in reply to Re^7: ref to read-only alias ... why? (eval)
in thread ref to read-only alias ... why?

> That's an overstatement. The only thing that can be impacted is a sub that tries to modify an alias and then gets passed a read-only value and where that situation isn't just declared a bug and gets fixed.


> If no error is ever thrown, then nobody knows and nobody cares and there is nothing to fix.

Wrong, as you can see from the code I posted, not only the sub is affected, but the intended side-effect (of altering the call-by-reference argument) is missing without warning.

in continuation of Re^3: ref to read-only alias ... why? (not consistent)

DB<111> $x=0; for ($x,0) { print; inc_b($_); print " -> $_\n"} 0 -> 1 0 -> 0

> So, yes, exactly as I said, the worst possible case can be solved by adding a simple eval around the code that modifies the reference

How is eval supposed to help here?

> but is (badly) designed to also tolerate the failure in the case of read-only parameters.

So in your opinion manipulating $_[0] is a bad design!?!

Could you please post some code-examples to illustrate your point of view?

Cheers Rolf

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://947073]
[Discipulus]: good morning choroba! the eu-crew is complete! ;=)
mxb waves

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (10)
As of 2018-05-21 08:08 GMT
Find Nodes?
    Voting Booth?