Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116056 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 28094 invoked from network); 17 Sep 2021 04:09:00 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Sep 2021 04:09:00 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E11FE1804C0 for ; Thu, 16 Sep 2021 21:48:52 -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-f176.google.com (mail-vk1-f176.google.com [209.85.221.176]) (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 ; Thu, 16 Sep 2021 21:48:52 -0700 (PDT) Received: by mail-vk1-f176.google.com with SMTP id h132so3244170vke.8 for ; Thu, 16 Sep 2021 21:48:52 -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=N0bpxg17rd/gdN6ndhs/EMApxxAJBk+wTOpkTwDnYNk=; b=YWqaW5OCQS6tvCgQEX339cCAKrVgE5aNHCgN+eZ3F46cE2Rwj3qjciEDxIY+q80s0q f3Rr4esYyogHe1f4bUgRBpafptl4zwGxfBtIwwza2AryHhHgascNEAUhWJyGueadO4I8 tQ1KJ4Xp7xvtoIuxLQrVPpzcFvkOrwLGwztZa0f1cfnGri30hk8TY0fmKYEWaHtHDuza 31oFOoTFXFmAG+ZjOuX7n9kRNj1Ho88jJ6UOXxtmBAh0ECCiuu05ykqc19A72PSjDVAH 0SLuV+AvqnEWlucynBB5ko0jyN/bTZvqAz/bpkgNR/Vg3Awk/V1YFtaMhdLWr7VO9OSB cYeA== 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=N0bpxg17rd/gdN6ndhs/EMApxxAJBk+wTOpkTwDnYNk=; b=AbF29DvlrMfCjy57wYzvMq+e4sUYrHq8aBDYQBGO4t+r4/vCRcitwtZ/7rTGYbqBsa e8qbUCxYPN6qlgmxlSkmIpXfWMNcT72O4nodA2+PI60T6fNQR9UQIpmVacqR8rAjHif+ 0Fhz+eH/cv+mjBazalCI4wNVkdyrV94SDAuQduDPuFnJAEXzOHpiniYiG6QYf2AfwRJO 7yc0nKhLq4sCoUGIGxo7SI2Q3mL8ajshprilo+M/Sgz2VIek9wwPRVY/uX+p5COq00K5 4C+0Ea46xjJmS7ZWXF+tZ0b5CwZGmpCERUx2TlO9nRqB2BPAseNkiAGlXaPdAY5Qad8u BLLw== X-Gm-Message-State: AOAM531FIJ/tG62LVHQ/8uuGfJGMA4Ex3yutUCQPz5V0CAOdEr5pwnN7 ekO0Zl6wDvw8U9H97+HiDDtUjfuZCIHZmTCvAKo= X-Google-Smtp-Source: ABdhPJzQ7WoE/K0iF3qFZUs9nMFgcDMr0rHaDszNRx5Kn+OsuEJCggnQD46UbQ7cqgw8Vieiqm6rWlysUkC9BPoLKvs= X-Received: by 2002:a05:6122:d95:: with SMTP id bc21mr6544205vkb.23.1631854129343; Thu, 16 Sep 2021 21:48:49 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 17 Sep 2021 00:48:38 -0400 Message-ID: To: tyson andre Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary="000000000000b46ffe05cc29a57d" Subject: Re: [PHP-DEV] RFC: Add `final class Vector` to PHP From: matthewmatthew@gmail.com (Matthew Brown) --000000000000b46ffe05cc29a57d Content-Type: text/plain; charset="UTF-8" On Thu, 16 Sept 2021 at 23:33, tyson andre wrote: > Yeah, as mentioned in > https://wiki.php.net/rfc/vector#adding_a_native_type_instead_is_vec , it > would require a massive amount of work. > > - A standard library for dealing with `vec`, filtering it, etc > - Userland libraries and PECLs would need to deal with a third complex > type different from array/object that probably couldn't be implicitly > - Extensive familiarity with opcache and the JIT for x86 and other > platforms beyond what I have > - Willingness to do that with the uncertainty the final implementation > would get 2/3 votes with backwards compatibility objections, etc. > I feel like the standard library could be added in userland first, and then corresponding faster implementations could arrive in the std lib. But the last point is a really important one, and feels like a weakness in the RFC process. I know RFCs without implementations are generally frowned upon, but if 2/3rds of the community agreed that they wanted some sort of vec[] support in theory, it might then free up the implementer(s) to take a more granular approach to supporting vec. It could, for example, be an experimental feature for a minor version. Best wishes, Matt On Thu, 16 Sept 2021 at 23:33, tyson andre wrote: > Hi Levi Morrison, > > > I'm okay with a final Vector class in general. I don't love the > > proposed API but don't hate it either. Feedback on that at the end. > > > > What I would _love_ is a `vec` type from hacklang, which is similar to > > this but pass-by-value, copy-on-write like an array. Of course, this > > would require engine work and I understand it isn't as simple to add. > > Yeah, as mentioned in > https://wiki.php.net/rfc/vector#adding_a_native_type_instead_is_vec , it > would require a massive amount of work. > > - A standard library for dealing with `vec`, filtering it, etc > - Userland libraries and PECLs would need to deal with a third complex > type different from array/object that probably couldn't be implicitly > - Extensive familiarity with opcache and the JIT for x86 and other > platforms beyond what I have > - Willingness to do that with the uncertainty the final implementation > would get 2/3 votes with backwards compatibility objections, etc. > > > Feedback on API: > > > > - `indexOf` returning `false` instead of `null` when it cannot be > > found. If we are keeping this method (which I don't like, because > > there's no comparator), please return `null` instead of false. The > > language has facilities for working with null like `??`, so please > > prefer that when it isn't needed for BC (like this, this is a new > > API). > > I hadn't thought about that - that seems reasonable since I don't remember > anything else adding indexOf as a method name. > > > - `contains` also doesn't have a comparator. > > I was considering proposing `->any(callable)` and `->all(callable)` > extensions if this passed. > I'm not quite sure what you mean by a comparator for contains. There'd > have to be a way to check if a raw closure is contained. > > > - Similarly but less strongly, I don't like the filter callable > > returning `mixed` -- please just make it `bool`. > > The filter callable is something that would be passed into the filter > function. The return value would be checked for truthiness. > The phpdoc in the documentation could be changed, but that wouldn't change > the implementation. > > > - I don't know what `setSize(int $size)` does. What does it do if the > > current size is less than `$size`? What about if its current size is > > greater? I suspect this is about capacity, not size, but without docs > > I am just guessing. > > It's the same behavior as > https://www.php.net/manual/en/splfixedarray.setsize.php . It's about > size, not capacity. > > > Change the size of an array to the new size of size. > > If size is less than the current array size, any values after the new > size will be discarded. > > If size is greater than the current array size, the array will be padded > with null values. > > I'd planned to add phpdoc documentation and examples before starting a > vote to document the behavior and thrown exceptions of the proposed methods. > > Thanks, > Tyson > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > --000000000000b46ffe05cc29a57d--