Newsgroups: perl.perl6.language
From: n...@unfortu.net (Nicholas Clark)
Date: Tue, 13 Aug 2002 21:33:32 +0100
Local: Tues, Aug 13 2002 4:33 pm
Subject: Re: Autovivi
On Tue, Aug 13, 2002 at 03:06:40PM -0400, Deven T. Corzine wrote: Well, perl5 does already manage to avoid auto-vivifying hash keys when they > 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. are used as subroutine arguments. It uses magic, rather than dataflow analysis: $ cat autovivi.pl sub rval { } sub lval { $_[0] = undef; } sub dumpit { Dump ($_[0]); } my %a = (camel => 2); rval ($a{llama}); print "rval: @{[keys %a]}\n"; lval ($a{alpaca}); print "lval: @{[keys %a]}\n\n"; dumpit ($a{dromedary}); __END__ SV = PVLV(0x1134d8) at 0xf4368 As you can see, the ingredients for "magic" are quite cumbersome, but do get Nicholas Clark You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||