☞ | ![]() ![]() |
19 |
Another serious error:
Observers aren't garbage-collected properly
The module must use weak references to garbage-collect them at all
But then they are collected prematurely:
my $alarm = Alarm->new(); $alarm->add_observer(Guard->new); $alarm->notify_observers("I like pie!");
Failed to send observation from 'Alarm=HASH(0x8113f74)' to '': Can't call method "update" on an undefined value at lib/Class/Observable.pm line 95.
What happened here?
The Guard object was garbage-collected
The reference to it that was stored in %O became undef
☞ | ![]() |
☞ |