Consider this:Is this not tampering? Your statement is correct in a copy-by-value world, but not in a copy-by-reference world.my @args = ([1, 2, 3], "hello"); push @callbacks, sub { $_[0]->[0] = "tampered" };
Yes, so? You have not been any more paranoid than me. Your code does not make a deep copy of @args so your validate() has no chance of detecting that sort of tampering either.
Btw, "strictures[1] and friends" means "strictures and other stuff like strictures", not "use strictures and have co-developers you are friends with".
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.
You are confusing a statement of fact for an opinion on style. There are two reasons to add validation code like yours, and in neither case does it make sense.
The first is when the data examined is user input. But if it's code that you have been fed by a user, such as would be the case in this example, you have lost right away. Even if you made a deep copy, someone determined enough could use PadWalker to tamper with your original @args as well as their copy and you'd have no way to detect that. If it runs inside your Perl interpreter, you better be able to trust it.
The other is if you want to guard against your own mistakes — the same reason to rely on strictures, enable warnings, use three-argument open(), and so on. But what does your validation code help? Look at it. Now look at the code I wrote. Which one is easier to maintain? In which one would bugs be easier to spot?
[1] Larry's term for the rules enforced by strict.
Makeshifts last the longest.
In reply to Re^6: Action at a great distance
by Aristotle
in thread Action at a great distance
by sfink
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |