On Tue, 13 Aug 2002, Nicholas Clark wrote: > On Tue, Aug 13, 2002 at 03:06:40PM -0400, Deven T. Corzine wrote: > > > The only accurate way to know if the code modifies the variables is to do > > some sort of dataflow analysis, and it can't be 100% accurate even then. > > (Suppose a "shift" may or may not happen, depending on the parameters, then > > $_[2] is modified?) Of course, it should often be possible (at least in > > principle) to determine that it's impossible for a particular parameter to > > be modified, and play it safe by assuming "is rw" for undeterminable cases. > > Well, perl5 does already manage to avoid auto-vivifying hash keys when they > are used as subroutine arguments. It uses magic, rather than dataflow > analysis:
Yes, "magic" obviously can work, but it's a greater run-time penalty -- if you do some sort of dataflow analysis, you pay the penalty at compile time instead. I'm not sure which is better, ultimately. It probably varies. Anyway, the Perl 5 magic you speak of presumably only works for a single level of hash referencing -- we were specifically discussing a multilevel reference, which immediately creates missing substructures in Perl 5, even used in a read-only rvalue context in a simple Perl 5 expression... Deven