News for hackers. Stuff that matters.
Re:Lisphp is a Lisp dialect written in PHP. by jacquesm on Monday July 05, 2010 @12:02PM (#1488493)
Yes, that's what I thought, and I don't see a real way around it.

The bigger problem is in code that consumes the lists item by item, every time an extra copy of the remainder of the list will be made, there it is much harder to work around this.

Very neat code by the way, thanks a ton for making this.

I'll be playing around with it for a bit, I've written a chunk of code for a small site a while ago in a 'functional' PHP style (as in, no assignments except at the highest level), I'll see if I can convert that project to your lisp dialect and get it to work.

Re:Lisphp is a Lisp dialect written in PHP. by Scriptor on Monday July 05, 2010 @12:34PM (#1488554)
It could be mitigated in some cases as long as the garbage collector is working fine. For example, in a tail-recursive function that uses a first/rest pattern to go through an array a new copy would normally be allocated with each recurse. If LispHP can do some form of tail recursion elimination, it will theoretically take up constant memory and hopefully the GC takes care of the practical part.
Re:Lisphp is a Lisp dialect written in PHP. by jules on Monday July 05, 2010 @01:45PM (#1488694)
Even if memory usage weren't a problem you still have O(n) time for cdr. This may not be a problem if you implement the higher level functions (map, filter, etc.) efficiently.
Re:Lisphp is a Lisp dialect written in PHP. by eru on Tuesday July 06, 2010 @09:24AM (#1490871)
Yes, higher order functions (especially foldr (resp. reduce)) are the way to go.