Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121423 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 26983 invoked from network); 18 Oct 2023 20:45:39 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 Oct 2023 20:45:39 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 79340180546 for ; Wed, 18 Oct 2023 13:45: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,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 18 Oct 2023 13:45:38 -0700 (PDT) Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-3b2e308a751so59573b6e.0 for ; Wed, 18 Oct 2023 13:45:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697661937; x=1698266737; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=kkquczGbyhGRC2m8IvdDlTQlYZx17A81YWMgyFesRyI=; b=M2uUW6rG89SE9Du6mdgewhpfUfQMulGxL+UjypUhJWz9oHNvRzPZFm5k+qGsdNTCyN 3tX3w2nXYdhdv5b0b8n4PLL9jTQLfayzWQiGyxfAiiqCLi5mSSJk/5OxdfbvfhS7OwZe aH+aV1pK+UTBrvazFkQCdIAB5yIVNnfJIpXonrhIEssnd1+mZucfLhFEeVb15EGVmIS/ 1vcZeJjQro3euzAJS/nTeSEIljSgDNOJD0T4k7S6643EkPSYt7n0+ni4ToCZ/x48iJ48 MmyYPRZ1Stnk/kAKJhTjLUPRm0mlXi/TwHPcW451Rabk8cETpbAnEgycoRSEpKf4l22Q ZIKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697661937; x=1698266737; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kkquczGbyhGRC2m8IvdDlTQlYZx17A81YWMgyFesRyI=; b=QdT2NhjCCMRLiI/Rnt6eI/XsCGY1cLcLfaZrw10L6qLBamYH0UlcN4KYT6PXFpkqqz heTswHtYefByt9S0FHTey0ZJu52KcMZuBDDAcMES92yHIEwilFLXJsWSuDwHsq9hRqsH qAKWAzqAHTNhHD/a0asiZIC8k0SiVMqIx+dVtTMYdpNot4mEjju5qaCIu/YxFZC8usI2 0fwPLC4R51XvitVdvKQty85gqmqEjxYegh2EOJWOjdwfdzGDAEYiHKpa7oN6JFBW2YBp jpHhupIli4eiY1sSkHUZFCT66dNsUERw1GbI5mGwLErFU1/JMUpXHlGoNd1A7W4lyqGx e9jA== X-Gm-Message-State: AOJu0YwejZFfkf3V3joakZ0VbmMPkbThTQLDhNZxMtHoK6HZbXYlif10 pWKHR2HSTgjHtQgDBB2O7F/k2twhY9LZbOjMaoY= X-Google-Smtp-Source: AGHT+IG2pXKAI/D+5+Scc8iaHRJqO6DPUeo3QeJjSgRtEqNWEpP1JONc2I6GuqREQVYaLOoE4q4bz3jykHrLNNrJgu4= X-Received: by 2002:a05:6808:1b11:b0:3a8:6a40:7dc0 with SMTP id bx17-20020a0568081b1100b003a86a407dc0mr3544897oib.18.1697661937103; Wed, 18 Oct 2023 13:45:37 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 18 Oct 2023 22:45:25 +0200 Message-ID: To: Jordan LeDoux Cc: Pierre , someniatko , php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Custom object equality From: landers.robert@gmail.com (Robert Landers) On Wed, Oct 18, 2023 at 10:22=E2=80=AFPM Jordan LeDoux wrote: > > On Wed, Oct 18, 2023 at 6:03=E2=80=AFAM Pierre = wrote: > > > Le 18/10/2023 =C3=A0 14:50, someniatko a =C3=A9crit : > > > Hi internals, > > > > > > This approach allows combining > > > - no BC break - `~=3D` is a new syntax which is unavailable in older = PHP > > > versions > > > - explicitly showing an intent that objects are compared using a cust= om > > > comparison, rather than standard PHP one > > > - allow to skip writing boilerplate equals() methods which just forwa= rd > > > equals() to the nested objects > > > - standardize such comparisons on the language level > > > > > > Of course how exactly this operator looks may be changed, `~=3D` is j= ust an > > > example. > > > > > > WDYT? > > > > I'm not fond of operator overloading, I actually quite hate it, I like > > the expressiveness of an equals() method. > > > > I would very much prefer to have a set of standard interfaces such as > > Comparable { compareTo($other): int } or Equatable { equals($other): > > bool; } which the standard API and userland libraries could make use of= . > > > > In all cases, I don't like the ~=3D choice because in my mind it litera= lly > > translates to "is approximately/barely/maybe comparable to". > > > > By the way, please do not use abbreviations such as WDYT, I'm not a > > native english speaker and I don't know all abbreviations, I had to > > duckduckgo' it. > > > > Regards, > > > > -- > > > > Pierre > > > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: https://www.php.net/unsub.php > > > > > While I (obviously) appreciate the goal of the proposal here since I wrot= e > the gigantic operator overload RFC the last time it was proposed, I do no= t > support this idea here for one very simple reason: it is a clunky, > work-around implementation to try and get the benefits of operator > overloads without actually doing it. > > The need to control comparisons is real and obvious. So long as voters ar= e > categorically opposed to actual operator overloads no matter the > implementation, as represented here by you Pierre but by no means a > position that only you hold, I don't think we should be looking for ways = to > get the functionality through hacks like this. It may get passed in the > short term and get PHP developers the equality comparison control that > objects desperately need, but it makes all future improvements almost > impossible to do. > > someniatko: > > If voters don't want operator overloads, then voters don't get the featur= es > of operator overloads. It's very much that simple. If you want this > feature, try and change minds (ha ha good luck). "Operator overloads don'= t > fit a language like PHP"... despite the fact that Python is the language > most like PHP in many ways and has some absolutely crazy operator > overloads. "Operator overloads make operators impossible to understand"..= . > despite the fact that this is already the case with existing operators an= d > magic methods. "There is no use case"... despite the fact that this gets > suggested by a different person like clockwork AT LEAST every version > because it is something they would use. > > Honestly I would give up on advocating for operator overloads someniatko > and just move to a language that has them like Python. That's what I did. > Your sanity will thank me. > > Jordan As a user of PHP, it was sad to see that fail. There are no "unsigned longs" in PHP, and I had to create a library that emulated them using GMP. There is no way to describe how terrible using that library was... simply because you couldn't overload a plus sign or an equals sign. Accidentally using real operators could cause all kinds of shenanigans and invalid math being done. Fun times. If it had been a possibility, we would have ditched PHP immediately. We almost did anyway, even if it meant rewriting everything. People seem to be hung up on "people might abuse it" and forget there are real-world, somewhat niche problems that are True Pain (TM) to solve without overloading. Pain enough to leave the language entirely. Thank you for your contribution, it was a really well-put-together RFC, IMHO. I would have voted for it if I could have. Robert Landers Software Engineer Utrecht NL