Date: 05/31/01
- Next message: Roy Huggins: "Re: [phplib] PHP and recursion"
- Previous message: Paul Smith: "Re: [phplib] PHP and recursion"
- Maybe in reply to: Roy Huggins: "[phplib] PHP and recursion"
- Next in thread: Roy Huggins: "Re: [phplib] PHP and recursion"
- Reply: Roy Huggins: "Re: [phplib] PHP and recursion"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
>From that very book, "Web Application Development with PHP 4.0", Tobias
Ratschiller, 0-7357-0997-1:
"PHP 3.0 doesn't have proper garbage collection. When reallocating a
variable, memory that's already been allocated is not always being reused.
... this might result in 'dead memory'"
In other words, check your garbage collection routines, and check to make
sure you don't have any "runaway" nodes. Since PHP works with "copies" and
not pointers, the whole concept of recursion can get tricky if you're not
really careful... THAT'S what Mr. Ratschiller was saying in this great book,
NOT that one shouldn't use recursion. (In fact, it's impossible to handle
tree structures without using recursion).
And BTW, see pg. 53 of the very same book. They go over a simple example of
exactly what it sounds like you're trying to implement.
-Sebastien
-----Original Message-----
From: Paul Smith [mailto:paul <email protected>]
Sent: Thursday, May 31, 2001 9:16 AM
To: phplib <email protected>
Subject: Re: [phplib] PHP and recursion
Yikes, that is dubious advice. Recursion is one of the things that
makes programming so great! It is a powerful concept, *not* some obscure
or obtuse feature. Casually dismissing it is akin to blowing off, say,
object-orientation, or abstraction. I highly encourage you to explore the
application of recursion further, not less, because it can dramatically
reduce complexity and reveal solutions that are otherwise unattainable.
On Thu, May 31, 2001 at 03:30:41PM +0100, James Johnson wrote:
> 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>
-- Paul Smith <paul <email protected>> InfoTech Designer Center for Neighborhood Technology Chicago, Illinois USA--------------------------------------------------------------------- To unsubscribe, e-mail: phplib-unsubscribe <email protected> For additional commands, e-mail: phplib-help <email protected>
--------------------------------------------------------------------- To unsubscribe, e-mail: phplib-unsubscribe <email protected> For additional commands, e-mail: phplib-help <email protected>
- Next message: Roy Huggins: "Re: [phplib] PHP and recursion"
- Previous message: Paul Smith: "Re: [phplib] PHP and recursion"
- Maybe in reply to: Roy Huggins: "[phplib] PHP and recursion"
- Next in thread: Roy Huggins: "Re: [phplib] PHP and recursion"
- Reply: Roy Huggins: "Re: [phplib] PHP and recursion"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

