This is great news. PHP doesn't have many structured data types, so arrays (aka maps) are basically used for everything. Any improvement to them will impact the entire application. It would be nice to have separate types for arrays and maps though. I don't understand why they were combined to begin with. Simplicity? Seems like there are more edge cases and gotchas the way things are now.
> It would be nice to have separate types for arrays and hash tables though. I don't understand why they were combined to begin with. Simplicity? Seems like there are more edge cases and gotchas the way things are now. There is no "hash table" type in PHP user land.
PHP 7's new hashtable implementation
11–20 of 137 posts
Re: PHP 7's new hashtable implementation
#12I wonder if the ->pDataPtr vs ->pData confusion has been resolved.
I'm probably a few years behind, but a lot of my confusion working with hashes has been that pair of void* pointers.
Re: PHP 7's new hashtable implementation
#13Earlier quoted context omitted.
> It would be nice to have separate types for arrays and hash tables though. I don't understand why they were combined to begin with. Simplicity? Seems like there are more edge cases and gotchas the way things are now. There is no "hash table" type in PHP user land.
There are no arrays in PHP. There are only hash tables that are called "array" for simplicity.
Re: PHP 7's new hashtable implementation
#14This is great news. PHP doesn't have many structured data types, so arrays (aka maps) are basically used for everything. Any improvement to them will impact the entire application. It would be nice to have separate types for arrays and maps though. I don't understand why they were combined to begin with. Simplicity? Seems like there are more edge cases and gotchas the way things are now.
Stack - http://php.net/manual/en/book.spl.php Queue - http://php.net/manual/en/class.splqueue.php PriorityQueue - http://php.net/manual/en/class.splpriorityqueue.php Real Maps - http://php.net/manual/en/class.splobjectstorage.php
It's a shame some people are not aware of these.
Re: PHP 7's new hashtable implementation
#15What happened to PHP 6?
e: Actually wasn't there a blog post posted to HN suggesting Perl skip to 7 too?
Re: PHP 7's new hashtable implementation
#16Earlier quoted context omitted.
> It would be nice to have separate types for arrays and hash tables though. I don't understand why they were combined to begin with. Simplicity? Seems like there are more edge cases and gotchas the way things are now. There is no "hash table" type in PHP user land.
There are no arrays in PHP. There are only hash tables that are called "array" for simplicity.
Re: PHP 7's new hashtable implementation
#17Earlier quoted context omitted.
There are no arrays in PHP. There are only hash tables that are called "array" for simplicity.
How do they maintain their order?
That's why the lend themselves to the same syntax so well.
Re: PHP 7's new hashtable implementation
#18This is great news. PHP doesn't have many structured data types, so arrays (aka maps) are basically used for everything. Any improvement to them will impact the entire application. It would be nice to have separate types for arrays and maps though. I don't understand why they were combined to begin with. Simplicity? Seems like there are more edge cases and gotchas the way things are now.
PHP has a standard library with plenty of collections: http://php.net/manual/en/book.spl.php Stack - http://php.net/manual/en/book.spl.php Queue - http://php.net/manual/en/class.splqueue.php PriorityQueue - http://php.net/manual/en/class.splpriorityqueue.php Real Maps - http://php.net/manual/en/class.splobjectstorage.php It's a shame some people are not aware of these.
Re: PHP 7's new hashtable implementation
#19Re: PHP 7's new hashtable implementation
#20Earlier quoted context omitted.
There are no arrays in PHP. There are only hash tables that are called "array" for simplicity.
How do they maintain their order?
This "bucket" also handles the collisions by using separate chaining. There is actually two "next" pointers, one for the chains, and one for the next element in order of insertion. Very confusing and requires reading through the code and playing with it.