Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128686 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 82D261A00BC for ; Fri, 12 Sep 2025 19:02:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1757703653; bh=y97yt0F9r0jp8Xub4BTQniKBOyHgOKaofBAyyQ3ksCA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=dSbVDILC2Fn0r3L5VkduBodQrOxfoFi/31UNPFS5YyLr6j9keYRqFnaHjSioBhUKt LLM2pGlCCwmzyUSekX7n6umaa6Z1UG26QG+JpP1M9RIkrGtjRu45MdswAs4dMC9gQB 6lQY7Q+iMkqtV43VgEKFcIMuqAFw4Bf4k/ageO5Dua05uynl1Xmy+I8t6+yoRiMu3B umrt0EJkF4o4rRFSfUDQmw6DvcN/xcexusD3ofD7b03ASJev6QgL3fLg7py6OnFYr7 p+950a0Z5OWOSqfSk8YU4oFTiaPimloEnu3qunJqfiyXbedBjrp/HFIud/fBJZ6a2n iV1MQcDjSy74g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5C1AE1801DA for ; Fri, 12 Sep 2025 19:00:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 12 Sep 2025 19:00:52 +0000 (UTC) Received: by mail-qt1-f176.google.com with SMTP id d75a77b69052e-4b494e774bfso7074361cf.3 for ; Fri, 12 Sep 2025 12:02:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757703737; x=1758308537; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=y97yt0F9r0jp8Xub4BTQniKBOyHgOKaofBAyyQ3ksCA=; b=D9uyEG2FYejsJSq3kV/H8gjXSmh/3UYP9bSYOeDaLld14ZZVdcj6otud9TPb+9ZYFF BaSOkLRPy7rzFyLeRuHDm1xB2gTzsL6MFXCs0yemYMTcq9Ofve4txM5wPYwEai8jJN7r HiBz9mNpifjwR97kAioTclv8DQnhTeoMksXCKADe2nJyZuh5wfXmCzheuW5glFT8iEb0 R+BJeTtv2K7WKKTZL9aB9O1yxxm+I3WNqViAaOMutYg2XzJ7vMBsmxJ4Ixo/8DPl+l+b XkHmAXJadNvny+IIV5UNy5Sw3EeESnv59lyJr8rTsA/Yc6S1PjlYzoZNYsUIwXNdbG9+ TgJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757703737; x=1758308537; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=y97yt0F9r0jp8Xub4BTQniKBOyHgOKaofBAyyQ3ksCA=; b=IaqpTDXOldsIVKzSBPSup+Pnc56mkWLlldnJAJdNarBZvfHvcpK3P/z8H06s9/15PP wQpPG/KkWEkgA1h48J/ETAjTZE51uQ3w4PhnDvfo+x1Koyb9g+MrIP5YGeyvXJcJ3MOa ukl8muk/Z+2z+B9Jt/Y4xFVwJDdtgHXxzhW43SnnCoe9kiG11gnPDUL4z6jUyB/dAFd/ 1x4/TPzJdnrc1khJG4rU6SXvDpGstKmWGwGmiig8krn+BQq9leXF+z4ekguBM9dbtEHe Ee/BRGJO/FGFnoS/mOrTTRw1etdXKvGM588AN/WMgt/RylOklP8MvNxwYDYuCvzynrk+ I1DQ== X-Forwarded-Encrypted: i=1; AJvYcCX7HLMrFFV1v2ypd0xVrOml7bk1NN5CnGX1s7kuq1VoRWSX8hwqTrhYb/EAsmp1FVT6sORrdZs3uTY=@lists.php.net X-Gm-Message-State: AOJu0YyXQaV05KIxQd8WuVIH4y1cFlcmJ9nKZ7aVWCf8Q/XwzkwA9iTy Djv91BMj4/AQsPoxW8vzkoeWolWfxeydMHdYRe+OjIMGCEANikwwtxI8tWELW+KuPlImwzrnnMN RtknbTS4J3bczBG2WU4E2WQ0UYmcSAuY= X-Gm-Gg: ASbGncuoBKeDoCmKUxYdqbKFu9S5OiRIAgIYF7E56X+lkiuYXekt7pEYusYyLipm9pC isYdcPwXmtGmPl7peaoBp8wsDQdcMfVnyEXdOYIcYKtcdOPJz7ZEhLxrb9L4IpwMrziAJGPU1tS R3aCMlZYQjdFS13rWIMi7sHHy8I6YTXmIPHb1GP7Gt2UMQfFLv6ngFbKHjhzNtfO6FCWXB97KzF HmiEt/DNYThbjIMMP7WSthFSoNhaCx2sDe6FAzjZ5eJqt+Y X-Google-Smtp-Source: AGHT+IEAHgAJg2FRrBE3Be3tFqo6vmewM+YhNjQvGHgWPtQ86DLpXbw5p4XujG+jr5cVaE2Fuh7GrF+yqkANQ7PVHf8= X-Received: by 2002:a05:622a:347:b0:4b4:9175:fd48 with SMTP id d75a77b69052e-4b77ce9d1a9mr37218021cf.0.1757703736843; Fri, 12 Sep 2025 12:02:16 -0700 (PDT) Precedence: list list-help: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: <23fc3c05-f238-44d5-9a27-778c73db4a23@app.fastmail.com> In-Reply-To: <23fc3c05-f238-44d5-9a27-778c73db4a23@app.fastmail.com> Date: Fri, 12 Sep 2025 21:02:04 +0200 X-Gm-Features: Ac12FXzSg-V8uOesNMn6HrodH2-XBT4AYHFSaA7VLVcoI3ViLLCnhy68n2_-n4k Message-ID: Subject: Re: [PHP-DEV] [RFC proposal] Syntactic sugar for array push() To: Rob Landers Cc: Ken Guest , internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000dae4df063e9f4aeb" From: dusankrehel@gmail.com (=?UTF-8?B?RHXFoWFuIEtyZWhlxL4=?=) --000000000000dae4df063e9f4aeb Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable [+] 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. pi 12. 9. 2025 o 16:23 Rob Landers nap=C3=ADsal(a): > > > On Fri, Sep 12, 2025, at 13:06, Du=C5=A1an Krehe=C4=BE wrote: > > Hm, I didn't know about $array[] =3D 1;. > > It would make sense if it were: $a[+] for push() and $a[-] for pop(). > > pi 12. 9. 2025 o 12:35 Ken Guest nap=C3=ADsal(a): > > But we already have $array[] =3D 1; - are you unaware of it or is there > some other benefit to what you are suggesting? > > What might interest people would be a syntactic sugar/shorthand for > array_pop but I have no idea what that might look like. > > On Fri, 12 Sept 2025 at 11:21, Du=C5=A1an Krehe=C4=BE wrote: > > A proposal to add syntactic sugar for array_push() in PHP. > > Syntax: > // now > array_push($array, 1); > > // new syntax > > $array[+]=3D1; > > > Du=C5=A1an Krehe=C4=BE > > > > -- > http://about.me/kenguest/ > > > I'd personally rather have sugar for array_unshift and array_shift, than > pop and push. > > =E2=80=94 Rob > --000000000000dae4df063e9f4aeb Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
[+]= array_push
[-]= array_pop
[-&l= t;] array_shift

array_uns= hift() is a special case of array_merge(), so it would then need syntactic = sugar for merging arrays, or rather a reserved merge.

pi 12. 9. 2025 o=C2=A016:23 Rob Landers <rob@bottled.codes> nap= =C3=ADsal(a):


On Fri, Sep 12, 2025, at 13:06= , Du=C5=A1an Krehe=C4=BE wrote:
Hm, I di= dn't know about $array[] =3D 1;.
It would make sense if it were: $a[+= ] for push() and $a[-] for pop().

pi 12. 9. 2025 o=C2=A012:35 Ken Guest <kguest@php.net> nap=C3=ADsal(a):
But we already have $array[] =3D 1; - are you unaware of = it or is there some other benefit to what=C2=A0you are suggesting?

What might interest people would be a syntactic sugar/shor= thand for array_pop but I have no idea what that might look like.

On Fri, 12 Sept 2025 at 11:21, Du=C5= =A1an Krehe=C4=BE <dusankrehel@gmail.com> wrote:
A proposal to add syntacti= c sugar for array_push() in PHP.

Syntax:
// now
array_push($array, 1);
=

// = new syntax

$array[+]=3D1;

<= div>
Du=C5=A1an Krehe=C4=BE



I'd pers= onally rather have sugar for array_unshift and array_shift, than pop and pu= sh.

=E2= =80=94 Rob
--000000000000dae4df063e9f4aeb--