Re: [phplib] PHP and recursion From: James Johnson (james <email protected>)
Date: 05/31/01

Roy

I seem to recall Tobias Ratschiller's book,Web Application
Development with PHP 4.0 talks about using recursion.
I think he says it can be useful under certain unusual
circumstances, but to avoid it generally.

James

At 09:07 AM 5/31/01 -0500, Roy Huggins wrote:
>Hola.
>
>My question is not related to PHPLib specifically, for which I apologize. But
>the members of the list have oft displayed good knowledge of the underworkings
>in PHP and I'd like to get some insight into something I've run into recently.
>
>I recently built a pair of classes whose purpose is to create a tree of
>TreeNode
>objects in which each node has one parent, many children and an array of
>arbitrary data. Performing operations on these trees uses a lot of
>recursion, of
>course. Upon testing one function that traverses the tree, creating an
>array of
>path illustration strings through the tree (i.e. $paths[0] ==
>"root:node1:node2", $paths[1] == "root:node1:node4:node7"), PHP quit while
>complaigning about using too much memory. My script was using a whopping 8
>megs!
>
>I examined my code to see if I was doing something stupid to fill up the
>RAM and
>didn't find anything (which, of course, doesn't mean it isn't there. :) But I
>wanted to get some more info on how PHP deals with recursion and whether
>or not
>people have any comments/caveats to express on the issue. I've been spoiled by
>Scheme and find that recursion is wonderful at times. I'd like to know if it's
>really a good idea to use it that much in PHP.
>
>Thanks in advance!
>
>Regards,
>Roy Huggins
>roy <email protected>
>http://www.royhuggins.com/employability
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: phplib-unsubscribe <email protected>
>For additional commands, e-mail: phplib-help <email protected>

James Johnson
Managing Director
Publitek New Media Ltd.

IMPORTANT NOTE: NEW ADDRESS

18 Brock Street, Bath, BA1 2LW, UK
T: +44 (0) 1225 780174
F: +44 (0) 1225 470047
Courier deliveries should be addressed to 'West Door'
Please amend your records and let your colleagues know

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>