Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116079 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 29867 invoked from network); 17 Sep 2021 20:16:35 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Sep 2021 20:16:35 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0EA6B1804C0 for ; Fri, 17 Sep 2021 13:56:38 -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,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-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.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 ; Fri, 17 Sep 2021 13:56:37 -0700 (PDT) Received: by mail-qk1-f176.google.com with SMTP id b64so21607993qkg.0 for ; Fri, 17 Sep 2021 13:56:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datadoghq.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=kNE7FxYysR+39NhT5Nxyb5p1wVcEk9fdwFDyFgYL0B0=; b=eu6l5zlNeEkkWqo9d7Yo0hfnlb+PLH1khSGwZuiq+Apc05E0s2jXuiIjSF2BQUlbj8 5Wj3aAfNanAZv/CTnBM7FJGIZSxsi7gPBfEXaiDUVJ1HxkS2Vnvcy8cKZu+mC3mSAupx 2mKzib78+F6Z5W6k8aOw1DBal+spJlNs1BKBM= 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:content-transfer-encoding; bh=kNE7FxYysR+39NhT5Nxyb5p1wVcEk9fdwFDyFgYL0B0=; b=gyhNElpguZk+Quo75OtHYB4Tb4VsoPZtKYTWmSQjQn2Gusegi8tOLxQx2bP9w/MDqs ZTHuSa7gRQzQ7BdgDH6dhtED1cgUMboONUDnEJiWZbOKszOBvyZV7UDg37gALa5xKuLo dOXpE6WdvdhCRNiVmRqHIx6uoSNFX5YdcIJeZ6aS+Myp+jUKdgu2vQHwIPsNbwmaVJCr Fos6aJrrJLjmkObhEQ97U/AzafHdpf+NpwmC18bh1HMjfSGmaH4A7Xm+H4HRENSil4M/ qqf2OpNP1Hhfhtd6Z8N8wzpLsKOonngkzduLjMBW4Uie3bnKAYugpuQ8yMK1pKLBf73K DHWg== X-Gm-Message-State: AOAM531DMlbEMKx9NQV/7sOEG/PGrtu29o33npj9vZHXcgSi/4Y/M983 npbxFlkWKz2DXQ00ky+7E8A2c0wmsZjwxJCY1qO2Kg== X-Google-Smtp-Source: ABdhPJyM+he1Vo3G3XrXcUQxODT79VAiB2BQv79aW36zJSGwKLvIPWXCYj5HZx9NGEGK/m5D9Ps9Om6ZW4Gt8f7RX7o= X-Received: by 2002:a25:1a8a:: with SMTP id a132mr15725767yba.478.1631912193510; Fri, 17 Sep 2021 13:56:33 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Reply-To: Levi Morrison Date: Fri, 17 Sep 2021 14:56:22 -0600 Message-ID: To: Larry Garfield Cc: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] RFC: Add `final class Vector` to PHP From: internals@lists.php.net ("Levi Morrison via internals") > * Whether or not contains() needs a comparison callback in my mind depend= s mainly on whether or not the operator overloading RFC passes. If it does= , then contains() can/should use the __compareTo() method on objects. If i= t doesn't, then there needs to be some other way to compare non-identical o= bjects or else that method becomes mostly useless. This is only partly true. Let's say we have a vector of some complex type A. There are legitimate reasons for using different ways of comparing As, such as when projecting sub-fields (for example, sorting by each member's name this time, but next time sorting by each member's location). Of course, if it passes, then using a type's built-in comparison overloading is a sensible default, but it doesn't remove the need of having a custom comparator. ----- I was tired when I originally pointed it out the comparator/equatable stuff, but Tyson was rightly saying that `any` solves this need, e.g. contains($value, $eq)) {/**/} // translates to if ($vec->any(fn ($x) =3D> $eq($x, $value))) {/**/} ?> However, it's not as clear what to do for `indexOf` where you care about the index it was found at.