3 ms·
I immediately went to see how he implemented lists too with this kind of concern in mind. One way around the list issue is to write/use a C extension that provi
by arghnoname 16y ago
I immediately went to see how he implemented lists too with this kind of concern in mind. One way around the list issue is to write/use a C extension that provides a true linked list data type. I checked and there is such a thing in PECL, though who knows about quality.
Of course, because of the whole shared hosting thing you'd have to fall back to a pure PHP implementation if the extension isn't loaded.
- Scriptor 16y agoFWIW, there's an implementation of a doubly linked list in the SPL. http://www.php.net/manual/en/class.spldoublylinkedlist.php http://www.php.net/manual/en/class.spldoublylinkedlist.php LispHP seems to use ArrayObject, though I'm not really sure how its performance is (googling indicates iteration is slow).
- arghnoname 16y agoIs that written in C? Implementing a linked list in PHP isn't difficult, but I'd imagine memory use would be prohibitively expensive. If that is not written as a C extension, and perhaps even if it is, presumably you'd get a big speedup if you implemented a list with common lisp operations in mind as an extension for a project like this. It could fall back to a PHP implementation if the extension is not/can not be loaded. It's kind of moot because if speed were a huge concern, this might not be used in the first place, but just it would be interesting to see how far such a thing could be taken.
- jonursenbach 16y agoAll SPL classes/methods are written in PHP. They're essentially PEAR classes that just come preinstalled.
- Scriptor 16y agoIncorrect. The SPL is entirely implemented in C.
- jonursenbach 16y agoHuh interesting.
- salathe 16y agos/entirely/also/
- arghnoname 16y agoAh, that's why my memory was fuzzy. I downloaded PHP and as of 5.3, the SPL does come with a double linked list, and a userland and C implementation are both in the tarball. Why is there a PHP version also?
- jacquesm 16y agoMaybe as a fallback in case the extension isn't loaded ?