☞ | ![]() ![]() |
36 |
What should this do?
my $g = Guard->new("Fred"); my $a1 = Alarm->new; $a1->add_observer($g1); $a1->add_observer($g1); $a1->notify_observers("I like pie!");
One notification or two?
How about this?
my $g = Guard->new("Fred"); my $a1 = Alarm->new; $a1->add_observer($g1); Alarm->add_observer($g1); $a1->notify_observers("I like pie!");
The manual has hardly anything to say about this important issue
It just barely admits that the issue exists:
copy_observers( $copy_to_observable ) We make no effort to ensure we don't copy an observer that's already watching the object we're copying to. If this happens you will appear to get duplicate observations. (But it shouldn't happen often, if ever.)
☞ | ![]() |
☞ |