Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114700 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 4594 invoked from network); 2 Jun 2021 23:01:42 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 2 Jun 2021 23:01:42 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 24E161804AE for ; Wed, 2 Jun 2021 16:15:05 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 2 Jun 2021 16:15:04 -0700 (PDT) Received: by mail-qt1-f181.google.com with SMTP id m13so3104966qtk.13 for ; Wed, 02 Jun 2021 16:15:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=OcP+2ZMgj3H+539Aj0Qu1bE75PRsVHnjQ09t6N04gak=; b=kOI5D2uFS+MBY+u5Ppi/Hl3uNjtSNwTvvXgwYFlkqykkwFKy7mh9MvdAlrqx7KO+GY 0d+ocRip0wEsEanBaW3R0qnk4hulh54h9TOQ59ymf9mMcddAceA8pKFkEpCsP5cuYf7Y UgcPO8tjKEznliiU2BsTVidmh9zSx7ghrnU3Gu/pPCZ6IDs+lmqPTkRpC7LCyBfiaISR nyxxX0lxrM8sMIjIxkwX37ZhLGK3uuxOm924ErtdQdddaKo0DuivTYYXln+DfLjJO7N4 0kphSi+25O04FuYfkpG/SU7ubjLLs4isC1JPRr+ZZskVx9TRtbxyUD04sNoXJMXO+Nur ac0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=OcP+2ZMgj3H+539Aj0Qu1bE75PRsVHnjQ09t6N04gak=; b=QA6aoGQhXa+AGtyYJ1UiCiAEwp7QlH37kWNAI/qycH33GmtKsulYKSR/SBzc0NXOnF hTJGdUIs2Jyk2RqVjjbzlL0tiXALWbNCX6fK16/QgGzsNZ9mo8TnGr0TUMzvKaa0U7dN tYu/CCBM7fD7uehnO+gTT5VLFcuIdj3DCCk038KEQCo1W4i04KnBAFgtmz4uOKD3J4Q4 km1O6NilUTBQ5ZCu2ePl30hAAY7G72j+izSWLcbeFi2JT/se0MoPbB3C+KToc1+iyBho pGv29fjCOwIAxpFVfBBMAAxEHCd2t2FD/TPPORwF05xrUBBDuTOomUQq9hHMMnC2H2dV hyxA== X-Gm-Message-State: AOAM532/OKGxgL8JCYn5wzlhEns0NMTd3u/TZ4O/y+TcuiQ8cOphysDg LuSubHvzRAVpH/73LHMw7rolnyzqs5BNdzln X-Google-Smtp-Source: ABdhPJwUe+qWOx1vDB6xh1qtjXC1/qpvuYBOv2Qkd/YLKSCfq1vE74jUBrs4akp6VF0Gxvltfxj1zw== X-Received: by 2002:ac8:6d15:: with SMTP id o21mr9963844qtt.54.1622675704025; Wed, 02 Jun 2021 16:15:04 -0700 (PDT) Received: from [192.168.1.10] (c-24-98-254-8.hsd1.ga.comcast.net. [24.98.254.8]) by smtp.gmail.com with ESMTPSA id c23sm789215qtq.87.2021.06.02.16.15.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Jun 2021 16:15:03 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.6\)) In-Reply-To: <0857bb8b-456f-41d3-9a51-35f9ab629e61@www.fastmail.com> Date: Wed, 2 Jun 2021 19:15:02 -0400 Cc: php internals Content-Transfer-Encoding: quoted-printable Message-ID: <7722B520-327C-4F88-BD7D-208644D62A64@newclarity.net> References: <761D99C1-4728-4EE8-95F8-44A240AE1473@newclarity.net> <0857bb8b-456f-41d3-9a51-35f9ab629e61@www.fastmail.com> To: Larry Garfield X-Mailer: Apple Mail (2.3608.120.23.2.6) Subject: Re: [PHP-DEV] Regarding array_shift()/array_unshift() From: mike@newclarity.net (Mike Schinkel) > On Jun 2, 2021, at 7:07 PM, Larry Garfield = wrote: >=20 > On Wed, Jun 2, 2021, at 5:59 PM, Mike Schinkel wrote: >>> On Jun 2, 2021, at 4:25 AM, Jordi Boggiano = wrote: >=20 >>> IMO for unshift() it'd be fine to return a new array, but when = processing a list of things in a FIFO pattern I often used array_shift() = to get the first "job" out of the array. If $array->shift() returns a = new array then how do I access the first item? >>=20 >> That is a really excellent point, something I did not think to = consider=20 >> given how rarely I use array_shift(). =20 >>=20 >> But your comment causes me to ponder a number of follow up questions,=20= >> some of which are tangential. If any reader feels these tangents are=20= >> worth discussing please make another email and quote my relevant=20 >> comments so we can have a dedicated thread for each. >>=20 >> 1.) Given Nikita's position that it would only be viable to offer a=20= >> syntax that simulates method calling for arrays if the methods=20 >> themselves are immutable can you envision a solution for allowing =20 >> $array->shift() functionality that would address getting both element=20= >> and shifted array without resorting to by-reference parameters? >=20 > $list->head() (returns first item) > $list->tail() (returns all items but the first one) I assume $list->tail() would still have the O() problem in PHP, = though? -Mike=