On Tue, Nov 17, 2009 at 2:27 PM, David Nicol <davidnicol@gmail.com> wrote: > 1: are there situations where a RAIL object will be the subject of one of > these functions? > (resource acquisition is locking is the big design pattern that relies on > timely destruction) > Yes. I previously gave the following example which demonstrates resources being help until global destruction (marked by "G") rather than being released timely: # Timely release >perl -le"{ my $x=''; $x = bless {}; } print 'G'; DESTROY { print 'D' }" D G # Resource held until global destruction >perl -le"{ my $x=''; vec($x,0,1)=0; $x = bless {}; } print 'G'; DESTROY { print 'D' }" G D Here's an example that uses lvalue keys(%h) in the most straightforward manner: perl -le' sub init { my %h; keys(%h) = @_; %h = map { $_ => bless {} } @_; return \%h; } DESTROY { print "D" } { my $h = init(qw(a b c)); } print "G"; ' GDDD 2: can TARG be a weak reference using current weak reference technology? > That was mentioned earlier in this thread, and seems from a high and distant > level to be the way to go. > Yes, I believe so. What's wrong with that suggestion? The only downside is overhead. It makes yet another variable magical (the var passed as an arg). I can write up a patch tonight if you wish. Should I only use weaken when necessary (lvalue subs)? When does TARG hold the last reference to something, > See the reply to your first question. can TARG manipulation stuff simply leave reference counts alone? > If these ops couldn't be used as the return value for lvalue subs, I believe we could do forgo ref counting. I don't think that's a condition we can meet. EricThread Previous | Thread Next