On 12 September 2025 20:02:04 BST, "Dušan Kreheľ" <dusankre...@gmail.com> wrote:
>[+] array_push
>[-] array_pop
>[-<] array_shift
>
>array_unshift() is a special case of array_merge(), so it would then need
>syntactic sugar for merging arrays, or rather a reserved merge.

array_unshift is no more a special case of array_merge than array_push, 
particularly in the single-element case we're talking about here - it's really 
just the same operation at the other end of the array. 

Since we have an extremely well-established array_push shorthand, so don't need 
a new one, we could perhaps have "<" for "at start", and "-" for "pop":

$foo[] = $toPush;
$popped = $foo[-];
$foo[<] = $toUnshift;
$shifted = $foo[-<];

I'm not totally convinced it's necessary, but I don't completely hate it.


P.S. Quick reminder to all contributors on this thread that the policy here is 
to reply *below* the relevant quoted text, editing as necessary; do not reply 
*above* the entire quoted thread.


Rowan Tommins
[IMSoP]

Reply via email to