Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116092 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 19982 invoked from network); 18 Sep 2021 20:13:12 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 Sep 2021 20:13:12 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BC0631804B3 for ; Sat, 18 Sep 2021 13:53:28 -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 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 (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 18 Sep 2021 13:53:28 -0700 (PDT) Received: by mail-vk1-f172.google.com with SMTP id f73so3249640vkf.6 for ; Sat, 18 Sep 2021 13:53:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=JbDwUNCJ4kU7TxBjRuwHjYcHTZIsV7WiOvOhTob8ILk=; b=pjThB0NEi7LhLPP+Gfl0w8sjPVtSQfr/E4CCE2JR9zvYMOmWNSqy9N83IGk5cnddGl rkinJbJKJ/+X30Swa62JELjJkqd61D4wUrbz4R4xzGq3X3Z+iT5oKNFD1BxsMSOrJdM5 ZH6EtDYWD7sghE3UlxQpMKetqlGfPF2VPrhUHl808Fqza0MbChahKQzvAUtEy1HGeX79 tDSMRUOAgcbaHLgEl37EgLRrVymTTi1hEfkhp5ZoAggglt5zsdzKXHRDg8sIvXibXU9V YBquehBr3YsbzXyWYAKPl0aLfIHLAlj6voNw5NPKuSBQpwo1TiWGwSFtQ9Rnvbz2HDpa oFPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JbDwUNCJ4kU7TxBjRuwHjYcHTZIsV7WiOvOhTob8ILk=; b=m6ZBFm8w0hy94Biz6uL8DFqqX62ebhV2/OCyG5ppeS33d6jViPcXjrInAsMMvBOPdR Hvy5x+I9aMPtVsttvavI0VY8VPHH2g9IVhxUQIC/OpS/+V3sf6k2UZ1VZit6VyHXIsIm OIgKF1Xi+6BCX4YPvcT6bM2OYLO8JZb6zvSkz9GFcYa+E4xU1S6qmLutjNYjb4I7wxAQ i6UOkfc13saFecfLbKaVsilxfUxx0SxpVE+0DKXobNNoitB4so0oGEJIcK4GzMo8LrwI BHTpgiohiN8X+Y9PxDVcv7oZ9PRTQS8YjngjdMHlJTrA5ptzx7GTz1IORP+m/YiKjWvP Skzw== X-Gm-Message-State: AOAM531OPDxl8xMRtMwlpWkkmZZPyNS9n7dq8/52P9ZBjzCGGicUaXvG Tq5T/JGHlF35uJE/D3d+ePKdCZrpPyN24A+OukP6jTNJ X-Google-Smtp-Source: ABdhPJz4yXNoV3AwWUf6fkgkjmp8OX038Ax6tV0KI88u/kS1lNd1T9ziawyzQtKa1I9mN7NJs0fmBD5R3ZnS6RFdbTg= X-Received: by 2002:a05:6122:2c3:: with SMTP id k3mr11455430vki.6.1631998406908; Sat, 18 Sep 2021 13:53:26 -0700 (PDT) MIME-Version: 1.0 References: <29eb9519-ab67-44b2-9d62-9c591715946a@www.fastmail.com> In-Reply-To: <29eb9519-ab67-44b2-9d62-9c591715946a@www.fastmail.com> Date: Sat, 18 Sep 2021 16:53:15 -0400 Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="000000000000515ddb05cc4b3de6" Subject: Re: [PHP-DEV] RFC: Add `final class Vector` to PHP From: matthewmatthew@gmail.com (Matthew Brown) --000000000000515ddb05cc4b3de6 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, 18 Sept 2021 at 12:04, Larry Garfield wrote: > > I am frequently on-record hating on PHP arrays, and stating that I want > something better. The problems with PHP arrays include: > > 1. They're badly performing (because they cannot be optimized) > 2. They're not type safe > 3. They're mutable > 4. They mix sequences (true arrays) with dictionaries/hashmaps, making > everything uglier > 5. People keep using them as structs, when they're not > 6. The API around them is procedural, inconsistent, and overall gross > 7. They lack a lot of native shorthand operations found in other language= s > (eg, slicing) > 8. Their error handling is crap > > Any new native/stdlib alternative to arrays needs to address at least hal= f > of those issues, preferably most/all. > Hey Larry, I believe 1. and 2. are an impossible standard for any PHP-based proposal to meet. If you want it to be (runtime) type-safe, that assumes the existence of runtime type checks which can quickly become a performance bottleneck. For 3, having explored immutability in depth with Psalm, arrays don't present any sort of challenge due to their copy-on-write behavior. There's a chunk of Psalm's codebase that makes heavy use of arrays, and it's still provably pure. 5: they're used as makeshift structs, but there's nothing preventing people using constructor property promotion and named parameters to model the same data. I think this is effectively a solved problem. No real debates about the 4, 6, 7 and 8, but I'm radically opposed to throwing out the baby with the bathwater here =E2=80=94 languages that have= solved these problems exist, but demanding a proposal pass a purity test means the PHP project is more likely to stay the way it is. Best wishes, Matt --000000000000515ddb05cc4b3de6--