On 26 March 2026 07:51:31 GMT, Rob Landers <[email protected]> wrote:

>And then my disk caught on fire and it was never archived. TL;DR: treating PHP 
>arrays as an infinite field of nulls has some very interesting mathematical 
>properties. No other language on earth gave you this.

I agree that some useful use cases have been "thrown out with the bathwater" by 
trying to make array access less prone to mistakes. 

I think the pragmatic response to that is to propose new features that cater 
*even better* to those use cases. For instance: 

- an "optional key access" operator like $foo[?'bar'] that makes the intent 
explicit but concise
- a PHP version of Python's "defaultdict", which lets you *choose* the default 
value for undefined items, rather than always null 
- copy-on-write structs with predefined keys


At the same time, PHP has always been a long way behind other languages when it 
comes to lazy lists and iterators; I would love to see:

- a "sparse list" type, where you can define the size and initial value without 
allocating memory for all elements
- lazy ranges
- built-in functions or operators which can operate lazily on iterators (i.e. 
without enumerating them)


These aren't trivial to design and implement, but it would be great to transfer 
some of the energy from "I don't like this thing someone else wanted" into "I 
want this thing as well".


Regards,

Rowan Tommins
[IMSoP]

Reply via email to