Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102717 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24566 invoked from network); 10 Jul 2018 14:46:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Jul 2018 14:46:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=danack@basereality.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=danack@basereality.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain basereality.com from 209.85.160.68 cause and error) X-PHP-List-Original-Sender: danack@basereality.com X-Host-Fingerprint: 209.85.160.68 mail-pl0-f68.google.com Received: from [209.85.160.68] ([209.85.160.68:43376] helo=mail-pl0-f68.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5C/77-15421-7B6C44B5 for ; Tue, 10 Jul 2018 10:46:17 -0400 Received: by mail-pl0-f68.google.com with SMTP id c41-v6so7724733plj.10 for ; Tue, 10 Jul 2018 07:46:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=basereality-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=TuukSwVUxkYt/oTOBGVRq4UcswMAZH64xW/i3PrUqn4=; b=WtWz5kwLb+dL3ACh0tsrUe9tsOeyT2R/XWaJKVpOLqyR1ZF5GVt9aiELHX04xHTtrD 85FR0rmiX1ez+/jGGwdu2yVCCzfaFpopMLuz45ooTuuXa1UnmoQMl0AuqeWPPwCeKsI5 Do8JN9bxYqsfyDr5Md647OKYw/UU1Hhi8c6AIlnOf3FasxrDmr1PCSMBPQBrva5JWo0D zea0THHnYSQ3k+WiLqeN3aafoHEuW6C6UfEeX4h8M0ESB4fa9/PovD5rZVfXkcOUHHuX 1I3M0Rix4kKJi6pzno5Hiiv/5D5bnobBGVPfhMw2eC/ZsSBrbpOEC5i26zTV2sombeLi BS/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=TuukSwVUxkYt/oTOBGVRq4UcswMAZH64xW/i3PrUqn4=; b=SfigaOhQX8tZwh7LnWtvnlDWBPdeqbjErIbmRQFhxtJPetD7hZInbTlr1Os/DcSVvr Zvl303uGrU6pqUhaobYZtgZ1OFhK4AGSllKd7jX4HpAuCIiXO2s3iPoCucm8jO86tqKM LYCKbqjSj98a0PVzXOhqQf6QsnLUYThgnJtcY312VdRyzoo8KRVJzp+JKN71N0AXCxko WkaYkPsCREhiGXTWkivnnS6qgeZNW0B7sv6FKFrJFTgAGYdb4zXlEFlD6Cmb1UHSkXcO B34w3XfUkc3NbkajuObWdftOt9HWTa0LZY9fpst9rniCllxpdePRB/ssVk6E/MxSOh2w hU+A== X-Gm-Message-State: APt69E3kfxVHRXzNVsjvrUaRL94nlLHu37o/7B63DHSpfF8hXegSlz/p qwXJSQ09S8pq3TNoEZMsoTJoqIcuJcAIL70WLhgDqA== X-Google-Smtp-Source: AAOMgpfjRPjW+WTFTdy7JG/2qSV1LQ8vhrpWpRXmX8rnVkNH+MkPhCHmwtlEAtf1s4K22N8cLmfQ1/D9gPuu8ZPYzbI= X-Received: by 2002:a17:902:e85:: with SMTP id 5-v6mr24997211plx.318.1531233972701; Tue, 10 Jul 2018 07:46:12 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a17:90a:380d:0:0:0:0 with HTTP; Tue, 10 Jul 2018 07:46:12 -0700 (PDT) X-Originating-IP: [86.7.192.139] In-Reply-To: References: Date: Tue, 10 Jul 2018 15:46:12 +0100 Message-ID: To: CHU Zhaowei Cc: "Woortmann, Enno" , internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Re:[PHP-DEV] [VOTE] array_key_first(), array_key_last(), array_value_first(),array_value_last() From: danack@basereality.com (Dan Ackroyd) Also voting no, and wished I had mailed earlier. Accessing the keys and values separately is not a good design in my opinion, as it leads to: > All four functions either return the requested key/value > or null if an empty array is provided. Having what looks likes valid values returned for array_value_first() and array_value_last() A think a better pattern would be to return a tuple as Levi suggested. [$key, $value] =3D array_first($array); [$key, $value] =3D array_last($array); For people not used to returning tuples.....you should branch out a bit and try using them. They are a better pattern to use when returning multiple values from a function that don't need/deserve their own class/struct creating. cheers Dan Ack On 9 July 2018 at 18:31, CHU Zhaowei wrote: > I voted no. > I don't think we have an agreement on dealing with non-existing value, an= d the way this RFC proposed, just returning null without any notice/warning= , is wrong IMO. I know we already do this in other array_* functions, but w= e cannot keep making mistakes just because we already made same mistake. > > Regards, > CHU Zhaowei