Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112865 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 65564 invoked from network); 13 Jan 2021 11:24:17 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 13 Jan 2021 11:24:17 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id EFB451804F2 for ; Wed, 13 Jan 2021 03:02:28 -0800 (PST) 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, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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, 13 Jan 2021 03:02:28 -0800 (PST) Received: by mail-wr1-f54.google.com with SMTP id t16so1649719wra.3 for ; Wed, 13 Jan 2021 03:02:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=bhWYUQ2rgerJQGWOX8DHCXxI93bkvmIYQHvnbPY40Og=; b=n4cvL+HQ48We8XLjz6apPmCIqeYS4c6PlcnrZ4rNqP7Io5D7JmvCYX/DYcDtPtG7KH I9w5sfxdPClNF3LpF188KtZmhD/RpPMj/5wTv+OsiJQqBpxPfEtI+BFRy9JLWj4Pvhgl aZsNQgSFlJVtyYA+wtqCosLJ1xx70C8RbaXA0iN10s+QLU82OWk28L/MhPJvfvM6BSad wu1GXE5UZKyKjsoXJ/6pmvLLyG1DhfHtwRTKmjsGAhLX+Y2FS1WjJqX5EhjEiidnhkVx sCMKo17M5/ORIU/A7J3ZLkbLvwOOGL9l8IMu6rfYHRr+fxNk1DJziiLD807MVtHLOm6i llNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=bhWYUQ2rgerJQGWOX8DHCXxI93bkvmIYQHvnbPY40Og=; b=InL0nIf3mwXdMQHoEPBGrI4v48UPjlclYvysUkRx7im66AaD9l660W8+KpA8/Gr4d/ 0pf+qKh8RkS9jPoJSqnifT66Lr2ZPG57LnvjZieVcqGTUtgXCKCX+VFDS3OiYeVTThCl MfN7MQ9S2p2Aj+xq4pUaJ8B19y6f4245hNIPH0vCZMOpAo5dh8Iq57dEqa+V9H8/bfwl VJDN0Hp9wOeKoVBMCGCUYVo4uOdWMiQOCZyxLT9kUxunSD6e9UI6tj3kzPrL1rKQBe+t yZpR3rPD/1daBf1k/6TPkkbGL076HbqKmASnvgdRHDpcVAap88o2Thnc1cigw7JkZFB6 dxQg== X-Gm-Message-State: AOAM530AE5kYBxZstN7CCglH3C6Ct6fZQ0DY/nCCSZaBDAhTTB9Y8jrY by1y+94jEZHXkLdu3ULyG+f8Qi5Kv7REMg== X-Google-Smtp-Source: ABdhPJwEMUkKejxSng1sVqg07+eX0nDWEOBoPeINZInV/D4sWa88J87vF7dHwuNr+GqumJ87TM8+8Q== X-Received: by 2002:adf:ee10:: with SMTP id y16mr2024952wrn.296.1610535745338; Wed, 13 Jan 2021 03:02:25 -0800 (PST) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id o124sm2478183wmb.5.2021.01.13.03.02.24 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 Jan 2021 03:02:24 -0800 (PST) To: internals@lists.php.net References: <39ccd4f9-cb63-549f-d34e-0c5e473598a2@gmail.com> <264023c8-e0d1-666b-f906-c7bc821ed2df@processus.org> Message-ID: <746fb631-f026-95e3-b90c-137a36e75edc@gmail.com> Date: Wed, 13 Jan 2021 11:02:22 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <264023c8-e0d1-666b-f906-c7bc821ed2df@processus.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] [RFC] Allow object keys in arrays From: rowan.collins@gmail.com (Rowan Tommins) On 13/01/2021 09:16, Pierre R. wrote: > Instead of trying to restrict types that can be used as keys, may be > this should be the time to have enumerables, lists, maps, vectors, > sets, types, dictionaries, ... in PHP standard library ? A third party > tool such as PHP-DS should be part of core API instead of being a > third party extension. For sure, that's why I mentioned initialisation syntax: if you can't use objects as array keys, you can't use an array literal to construct any other object which uses objects as keys either, so they're always going to look uglier: Compare: $map = new Ds\Map([]); $map->put($object1, 42); $map->put($object2, 69); $map->put($object3, 39); $map->put($object4, 101); To: $map = [     $object1 => 42,     $object2 => 69,     $object3 => 39,     $object4 => 101, ]; There's a bunch of other gaps, too: arrays are copy-on-write, can be used in constants and defaults, etc. If we want people to use something - anything - instead of arrays, these are the things that only the core language can provide. Regards, -- Rowan Tommins [IMSoP]