more notes - hash key destruction happens at the right point but still won't work
Matt S Trout [Mon, 15 Jun 2009 19:22:17 +0000 (20:22 +0100)]
notes/hash-key-destruction.pl [new file with mode: 0644]

diff --git a/notes/hash-key-destruction.pl b/notes/hash-key-destruction.pl
new file mode 100644 (file)
index 0000000..30ca719
--- /dev/null
@@ -0,0 +1,18 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use Variable::Magic qw(wizard cast);
+
+BEGIN { package Foo; sub DESTROY { warn "in DESTROY\n"; } }
+
+my $wiz = wizard data => sub { $_[1] },
+                 free => sub { warn "destroyed $_[1]!\n"; };
+
+my %objs;
+
+$objs{foo} = bless({}, 'Foo');
+
+cast $objs{foo}, $wiz, '$objs{foo}';
+
+delete $objs{foo};