On Fri, Nov 02, 2001 at 10:09:14PM -0800, Russ Allbery wrote: > > Why is it that a paragraph node doesn't have children, but has an > > HTML::ParseTree object that has children? It seems an odd bit of > > indirection, and I can't make out the motivation for it. > > You mean a Pod::ParseTree object? > > Because a Pod::Paragraph has additional information beyond what a > Pod::ParseTree has, I would assume, and is therefore implemented as a > wrapper object around a parse tree.
So am I correct in thinking the question is ... why doesn't a Pod::Paragraph have children but may have a parse-tree which does? The answer is because a Pod::Paragraph does not assume the use of a ParseTree. Pod::Parser lets you use stream-based or tree-based parsing. It tries hard not to presume you must use one or the other. Note that the parse-tree for a paragraph is not created for you - you have to ensure it gets created by first setting the parse tree when you call the parse-text method. You can use a Pod::Paragraph with Pod::Parser without ever explicitly using a parse-tree. The ability to use one is provided for you, but I didn't want to force it upon you. Also, it holds a reference because it needs to be a polymorphic-object. It does not insist that the object in question is actually a Pod::ParseTree, nor even a "proper subclass" of a Pod::ParseTree. It can be any object of your on concoction that implements the same basic methods as Pod::ParseTree (which is why there is an option to parse-text to give it your own "node constructor" function to return a reference to your own object instead of a parse-tree). Did that answer your question? -- Brad Appleton <[EMAIL PROTECTED]> http://www.bradapp.net/ "And miles to go before I sleep." -- Robert Frost
