Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121422 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 24326 invoked from network); 18 Oct 2023 20:22:47 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 Oct 2023 20:22:47 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E1DD2180543 for ; Wed, 18 Oct 2023 13:22:46 -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, 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-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) (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:22:46 -0700 (PDT) Received: by mail-oi1-f172.google.com with SMTP id 5614622812f47-3b2e44c7941so1021269b6e.2 for ; Wed, 18 Oct 2023 13:22:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697660565; x=1698265365; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=m3EfQ6qq+t338H7xxhzHYA0SHVckpgWjfL0IWvgKJMU=; b=f7S3H4Ad3T0LOKq4pWNPBCZKRJMUCqzPPjL6J4EXMzie0DfiDYC8U2WBt0zJlktQj9 E6twN+h+K8o0JEJ80FK2U5GDkMkYoCdRLgRBM7qmxSHSCi4qX72mbLU3P7y7qM+YS1Pb 0cyLVQ/nc2eXzNPPuo4isecPj2NbNdSAfeOlhI/K35BuvIvBVLwsQ1jeKo/SN11U/R4g lOG7SiEYrDQZhPlSMIcZx6QtrC3wXjzD9JwfmjinAXeTJWjIDNF6d4QLNV1EVcb4MmA1 Ou/LZ/IqzEM8Ajl1yj5ZQgQx6Yf+3kuMyP+zK7MXz3j6XBrqFw2PrVa2KGgFkfMQSWU5 ydQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697660565; x=1698265365; h=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=m3EfQ6qq+t338H7xxhzHYA0SHVckpgWjfL0IWvgKJMU=; b=q7QcK0igUYMyPOmfEFktyPCKXNQctuGIbm1MP+TMh9tCL/fhO3HidCJSYoZM0A4oVj RO6CCUnq9YlIZDAE+HucN9tpOqy1CkKT999hu+fGUUkc6FJ35gH8nXHvD7Z0nYQj8vyL Xj/tbORDiA2VZxS2HyBT4+3qfwbRQn+Hc8eZia1RqJCiEyKb3fcwLWYMPlBBYKkwDz9K mOl+pjCU9oIauCMfEEBrr/FdKD+4asPs7HGaWnVd5cfk0IU75IQMKwBtG1If2FKuvuUA bWchi9kxt3nC6fJ/F/a+bl0yl/9J8zlTen3IYWmV8tdY+/eSzukHPKEM4SLnZOyOt9Sn oRmw== X-Gm-Message-State: AOJu0YxetbRbaUMkdoWvO1mPSMeR8gvzZf5/k2W+xo1arfZEWCnpzjxa R4cbm8aRAZImbOPTpfgroy8S6waYt0aF+UxHVNI= X-Google-Smtp-Source: AGHT+IG5FnirQge7Fkm7pd9vllahML5OhcDegStHyNmalY6TmDj86X5AnunrTJhKFNPBUpVLOxzcaETZ3+//N7hf4V0= X-Received: by 2002:a05:6870:114f:b0:1d0:e372:6c2d with SMTP id 15-20020a056870114f00b001d0e3726c2dmr449285oag.0.1697660565678; Wed, 18 Oct 2023 13:22:45 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 18 Oct 2023 13:22:22 -0700 Message-ID: To: Pierre Cc: someniatko , php internals Content-Type: multipart/alternative; boundary="000000000000f772c40608036647" Subject: Re: [PHP-DEV] Custom object equality From: jordan.ledoux@gmail.com (Jordan LeDoux) --000000000000f772c40608036647 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Oct 18, 2023 at 6:03=E2=80=AFAM Pierre w= rote: > 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 PH= P > > versions > > - explicitly showing an intent that objects are compared using a custom > > comparison, rather than standard PHP one > > - allow to skip writing boilerplate equals() methods which just forward > > equals() to the nested objects > > - standardize such comparisons on the language level > > > > Of course how exactly this operator looks may be changed, `~=3D` is jus= t 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 literall= y > 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 wrote the gigantic operator overload RFC the last time it was proposed, I do not 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 are 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 features 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 and 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 --000000000000f772c40608036647--