On Dec 13, 2005, at 20:16, Randal L. Schwartz wrote:

Since it was an undocumented but counted-on interface, I'm not sure
how to resolve this, but I wanted to raise the issue here to start
discussion about resolution, and also to let y'all know that your
man commands will fail magically soon. :)

The quickest solution is for these modules to update their use of Pod::Man not to depend on the undocumented interface, and create a new parser object for every POD file parsed.

Changing Pod::Simple to allow reuse of a parser object could take several months. And I'm not sure it's a wise design choice anyway. If we assume serial reuse we could have a quick-n-dirty solution of simply trashing the state information at the start of every parse. But it wouldn't be thread-safe. For safe concurrent reuse, we're probably looking at pattern similar to Perl Best Practices' inside- out objects. Except that since it's only a single object, it only has one destructor. You would end up keeping around all the state information for every parse that's ever been done with a particular parser object, so parser objects reused for a large number of parses would be memory hogs. The solution for the memory hogging would be to create a new Pod::Simple object for each file, so Perl can garbage collect the object when it goes out of scope (generally looping over a list of files, so the parser object can be destroyed at the end of each iteration). Which is how it works now.

That said, even though there isn't a good general way to allow parser object reuse in all cases, it's possible to do it in particular cases. Pod::Simple::HTMLBatch is an example of this. Because it's dealing with a whole set of POD files, it knows when it's done with one file and ready to go onto the next one, so it just reinitializes certain information when it starts on the next file. I can see potential for a 'reinit' method in Pod::Simple that blows away the state information while keeping the option flags intact. Pod::Simple wouldn't call it for you, but it could at least allow you the option of calling it and provide an easy interface to do it. I'll have to think about that some more. Russ, would that help the modules that use Pod::Man, or is it really no advantage over creating a new object for each file?

Allison

Reply via email to