> 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


In reply to Re^8: ref to read-only alias ... why? (eval) by LanX
in thread ref to read-only alias ... why? by dk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.