Re: DEMOLISH and bad call to new()
[email protected] (Stevan Little)
| Newsgroups | perl.moose |
|---|---|
| Message-ID | <[email protected]> |
Ernesto, On Apr 6, 2008, at 5:24 PM, Ernesto wrote: > Hi Stevan, > there is a little misunderstanding: > The test file > > http://dienstleistung-kultur.de/moose/02_demolish_required.t.txt > > is actually a combination of three test files or runs (against > Moose::Object 0.11): Next time is might be better to supply 3 test files actually. Although to be honest this is just one bug, you are just illustrating multiple facets of it. > Ok, the patch has healed the bug, but you can't have the cake and eat > it too: > > Maybe it might be worth to notice, that now errors inside DEMOLISH > can't > be tested because of the localization of $@ - but wait: perltoot says > "So you are guaranteed that an object /eventually/ gets properly > destroyed, except in the unique case of a program that never exits." Ah, but you can't have *your* cake and eat it too either :) Perl's exception mechanism has some issues and so can't always be used completely reliably in edge cases like this. However, I think it is sane to say that Moose does not fix this, but instead enforces the idea that throwing an exception inside a DESTROY/DEMOLISH is just a bad idea. If you stop to consider for a moment that DESTROY is called by Perl and rarely by the user, the idea of catching that exception reliably is not terribly sane. > But these consideration might become too esoteric ;-) Yes, and I think if you have such specific exception needs that you should not use Moose's DEMOLISH mechanism but use the native DESTROY so that you can have the greatest control over the situation. This is one of those cases, and there exists a few, where Moose just can't fix Perl. > The devil is always in the detail ;-) Very true. If you have some time, it would be helpful to write something to be put into Moose::Cookbook::WTF about this, something under the heading "I threw an exception inside DEMOLISH and it disappeared". Thanks, - Stevan