I wanted to use Scalar::Util::readonly() to help distinguish between foo( 1,2,3) and foo( -one => 1, -two => 2, -three => 3),

That brings to mind "and I wanted a pony".

If you had come to me with that idea, I would have told you that you need to solve your problem in a different way. Even if you hadn't already found out that your trick is broken for some environments, I would have warned you that your idea is inherently fragile. It will be broken by a matter of optimization within Perl. There is no guarantee of the behavior that you assumed.

It is also extremely fragile in the face of simple changes to how your code is used. You should feel guilty considering making code that breaks between these two usages:

foo( -bar => 1 ); my %args= ( -bar => 1 ); foo( %args );

I think the better alternative is nearly obvious so I won't spend time describing it at this time.

- tye        


In reply to Re: -foo not readonly in fun(-foo => 1} in perl v5.8.7 (wishes) by tye
in thread -foo not readonly in fun(-foo => 1) in perl v5.8.7 by Jenda

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.