Hi Rowan,

Not really a "compelling reason why we should keep this inconsistency", but
I have occasionally relied on array autovivification *for sub-dimensions*,
e.g.:

```
function f(iterable $xs) {
    $map = []; // initialization!
    foreach ($xs as $x) {
        // $map[foo($x)] ??= []; not needed
        $map[foo($x)][] = bar($x); // autovivification
    }

    // Then e.g.:
    foreach ($map as $foo => $bars) {
        foreach ($bars as $bar) {
            /* ... */
        }
    }
}
```

(adapted from my https://externals.io/message/114595#114611 message in the
"Disable autovivification on false" thread).

On the other hand, I agree that `$undefined[] = $x` looks like a bug... are
both cases the exact same opcode? (if yes, I wouldn't really mind updating
my code, especially for consistency with other "append" operators like .=
or +=, and that could even be an opportunity to rewrite it in a more
"functional" style...)

Regards,

-- 
Guilliam Xavier

Reply via email to