Considering it is impossible for the callbacks to tamper with their caller's data using my solution, I don't see why one needs to try even harder.

Consider this:

my @args = ([1, 2, 3], "hello"); push @callbacks, sub { $_[0]->[0] = "tampered" };
Is this not tampering? Your statement is correct in a copy-by-value world, but not in a copy-by-reference world.

Unless you don't trust yourself, which is why we use strictures and friends.

In a large project, with many developers working with one another code/modules, the ability to rely on trust or friendship is a not always a reality or a good idea. And even if its your very best friend from childhood whom you would trust with your life, why leave a door open for him/her to make a small mistake and cause a bug as insidious as the OP's to crop up? Sure if you are building a program whose required degree of reliability is minimal, then go for it. But if someone is paying you money to build software for them, they have a right to expect that your software will do as much as possible to assure the correctness of all data being processed.

As for suggestion of reliance on "strictures" (and I assume you mean use strict), it would make no difference if you code is correct perl code, but incorrect for the task at hand. Strictures are nice, but they are not a bullet proof vest.

Perl is not a language for the paranoid, anyway.

Perl is a langauge which embraces diversity. Perl is a swiss-army chainsaw. Perl is a langauge where "there is more than one way to do it", and that includes the paranoid way. I do not think you should make sweeping generalizations like that, to each his/her own, and you have no right to tell me different. As far as I am concerned, you are free to code as you like, and I will never tell you different.

-stvn

In reply to Re: Re^4: Action at a great distance by stvn
in thread Action at a great distance by sfink

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.