Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121399 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 81277 invoked from network); 18 Oct 2023 15:37:55 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 Oct 2023 15:37:55 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 42F3D1804B0 for ; Wed, 18 Oct 2023 08:37:55 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-vk1-f172.google.com (mail-vk1-f172.google.com [209.85.221.172]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 18 Oct 2023 08:37:54 -0700 (PDT) Received: by mail-vk1-f172.google.com with SMTP id 71dfb90a1353d-49d20cf3729so485278e0c.0 for ; Wed, 18 Oct 2023 08:37:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697643474; x=1698248274; 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=FXh9DBcKOjxQE1utM2IO47Oo5PNbkr061TIPtgWqDJ4=; b=WWDoY7bb86+R+h8t/nKttlfl67pSHXcemjjVMU41O649PBMmViV412qfnQSKroB/JH zzbspAeQje+1bNDbnX7Ng2rv0N8Cf/mYOR0gzGhUNWrGzcerAYJ40UZ+6/9qRNTfspPc 57AgVh3i2WFepkD/tVOk4AKgLW14XkVHLHjwfu+koIuY1Fy3Zk/6/y0i/ckvvTYNJRr/ 1OXcUIysNLsDI7M5DgQ4bGsKG5cQrEbktTXd8lBAbbbs3OSQaMQb5JGDlk3sfvqtxQcw XeNPiNiLURDky4eeGlsffdNHAq/D3RAg9vH5mSd5ctKfA3o999vLfzF4c3Fsc27MI5BG Ucfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697643474; x=1698248274; 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=FXh9DBcKOjxQE1utM2IO47Oo5PNbkr061TIPtgWqDJ4=; b=N+3CU8PmatNOd3wwce2riAYe/o3OXDp9CW0nrNvp/x/edbBXGWmrF4JAeXrHWv1X+s ETSIkVTq8kMHAqoL1tI6/jeyNdKgXlLGWQqFEYt2jypasuRfhXsqAVAPKGvN1vnbL+yP jdXq39ktbochvvoSAsek4NcZjVtj4tFzqhaySr4nuA/uTSkx281NLkdgLMWdILzlgG+X nhxKVo1pgHMSf+W5j4qj9S8FWX1IhHs1Fu/lag4vqLPj61uldm8HQwamgFKQy+yb7E5o PD4X6Ddio54KGZXNb4ojUQ96phSjQf8z0Lv8Um1KH9jrlINII8+IZGmtMDjMdT5dWOsn pVdw== X-Gm-Message-State: AOJu0Yw4vFvK8gdizkIScmuKMwF0wB/Ckt/IkNjFeRZofFx6b38M1kwj ccY2LLO37tE9yNdccXYS+jobaqUUCvl5fnW3WWI= X-Google-Smtp-Source: AGHT+IHxBpKEAgtDYQqkFx9IOTnCqRJM8Eb7sP3TAxxe6sF7QYIBsTrSLCFhLQWLSs/BYtPJJKVXwDwvnQLpUyQah24= X-Received: by 2002:a1f:2394:0:b0:48d:8ba:b5d0 with SMTP id j142-20020a1f2394000000b0048d08bab5d0mr4253437vkj.0.1697643473763; Wed, 18 Oct 2023 08:37:53 -0700 (PDT) MIME-Version: 1.0 References: <173ca550-71a0-4bd4-96f2-b64b6155115a@app.fastmail.com> In-Reply-To: Date: Wed, 18 Oct 2023 12:37:17 -0300 Message-ID: To: Robert Landers Cc: Brandon Jackson , Saki Takamachi , Levi Morrison via internals Content-Type: multipart/alternative; boundary="00000000000035896b0607ff6c6f" Subject: Re: [PHP-DEV] Two new functions array_first() and array_last() From: deleugyn@gmail.com (Deleu) --00000000000035896b0607ff6c6f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Oct 18, 2023 at 12:04=E2=80=AFPM Robert Landers wrote: > > I completely understand what you're saying and I don't disagree with th= e > thought process. What I disagree with is your statement that you will > always use array_first() together with array_key_first(). When talking > about standard lists (indexed from 0 to upper-bound), array_first() is an > order of magnitude more useful than array_key_first() as we always know > what the first key is: 0. > > This is simply not true, 0 is not always the first key in a list, > especially after filtering it. Hence there is a need for this function > in the first place. > To give back on the same format, "this is simply not true". Here are the facts: - https://www.php.net/manual/en/function.array-is-list.php - Determines if the given array is a list. An array is considered a list if its keys consist of consecutive numbers from 0 to count($array)-1." - https://3v4l.org/JZS9N#v8.2.11 At this point I have nothing else to add to this conversation. You will either accept that it is actually possible to use `array_first()` without using `array_key_first()` or you'll keep believing that your knowledge and experience is the only correct one. I believe my reservations have been registered, I would not like to have `array_first()` behave in a non-obvious way (i.e. involving array $key) because it's useful for Fibers users. I believe that writing your own wrapper that always returns key and value simultaneously is easy and straight-forward and may even make it into the core in the future. Rather than trying to solve deep convoluted issues on version 1, I believe PHP could introduce the simplest version of the function first and later on add an array_first_key_value() in the future if needed. In fact, I encourage you to propose an RFC for `array_first_key_value()` as a solution for the problem you're raising. --=20 Marco Deleu --00000000000035896b0607ff6c6f--