Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121443 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 31479 invoked from network); 23 Oct 2023 15:14:27 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Oct 2023 15:14:27 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 83DFC1804B0 for ; Mon, 23 Oct 2023 08:14:26 -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=-0.2 required=5.0 tests=BAYES_20,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-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (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 ; Mon, 23 Oct 2023 08:14:23 -0700 (PDT) Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-53e3b8f906fso5272554a12.2 for ; Mon, 23 Oct 2023 08:14:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698074061; x=1698678861; darn=lists.php.net; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=V5iCBIL0sGkAg2Z94PC64GokyO7abXoSnY2SvgJN1iM=; b=HHWlO3h6pR5nDY5rORkGZPopQPa1Kmq72/zCSV+MdFdwEUQgls7eqBOAXcJ1AgKfVM hpmFaci+jGJe4C2jBYyhglmqmLCEtwMxZwGtfQo6f1EIMrYuO0FUVz9NrsCuMC/Q9lrQ 8Co7eD+P5ljM5Gw6YxqgwBt3Redv2Lt8yxNyao5y4bLh7LKR3YHIsjY1SFfO3XZRnD8l 8SFfK6FJyncBw4xVEqXSoQUY6f5IrQfBcDdPjILWlJ+3KELdbix2Sok+eRh0zVUGz9LT 2OeSx5Ohu5dNRUnuIrfnS7f4Nh9JjtaSOrT35TJCEnN8VXuNLcwqrcrNgu5iA8SZQ9WP CI2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698074061; x=1698678861; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=V5iCBIL0sGkAg2Z94PC64GokyO7abXoSnY2SvgJN1iM=; b=nVAx/VJW8ReoRPbv+Z5GiT93yi3OnyBp2o4XKg+DOIh93lNPZkTuROEGQcxxix6gf4 rU/3v1rF5huSzWdz/HG8l4uJE5toLqhBGJJ1wdZ84hqdu7g1tmsBSoAqsq/d0Wz1IoMo h6hMpGPVYQZKqygoHpptCpLsyH+p2g0g1XdCFw9vUt+mVU55LndpOC8Mk0IDU/R22P2Q H1OXmeXgdRVrpmv31CooqYpM3QkFhfyLE6sv4+kVP0Xw2+yGwUForNXMBYZbrg1XMC8D hqh6ZAe9I5mvce69ruA230B7t7/HLjgXGxAecx0cvRuBWDhZOmhPIov+a2Ysy/yc5AHM Vymg== X-Gm-Message-State: AOJu0Yzpln2iFCiPnEWib/kwKHlQZRWtGZnf2/bTutLiM2GzsH02JDh1 1uAd9WTCeeNjk2oLxrQO31jipK5ghp4= X-Google-Smtp-Source: AGHT+IGMyyecIYBsbzJLTGqDLNj3/kF6sZQHcuaIzH2lCswfyZ0k2AUAtwg+RnAG2uMhO4Hnkgnd4A== X-Received: by 2002:a17:907:948a:b0:9be:f6c0:7d73 with SMTP id dm10-20020a170907948a00b009bef6c07d73mr6480463ejc.74.1698074061410; Mon, 23 Oct 2023 08:14:21 -0700 (PDT) Received: from [172.30.2.8] (89-20-160-117.static.ef-service.nl. [89.20.160.117]) by smtp.gmail.com with ESMTPSA id a19-20020a1709065f9300b009b94c545678sm6757642eju.153.2023.10.23.08.14.20 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 23 Oct 2023 08:14:21 -0700 (PDT) Message-ID: <97e67da5-d54a-403d-be4d-ed275240442a@gmail.com> Date: Mon, 23 Oct 2023 17:14:20 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: internals@lists.php.net References: Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Custom object equality From: dik.takken@gmail.com (Dik Takken) On 18-10-2023 14:50, someniatko wrote: > This approach allows combining > - no BC break - `~=` is a new syntax which is unavailable in older PHP > 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, `~=` is just an > example. > > WDYT? > > Regards, > Illia / someniatko > One thing to keep in mind is that operator overloading already exists in PHP. And it is already in use in userland PHP too, for example when comparing DateTime objects. The limitation is that it only works for some objects: Those that are implemented in an extension. To me, the obvious way forward would be to lift this limitation. But... several attempts to do so have failed to pass. People are hesitant to unleash full operator overloading power to PHP developers. So, perhaps a simplified version of the RFC by Jordan LeDoux, limited to the `==` operator only, would stand a chance? It would allow the community to try their hands on this one (highly valuable) operator overload. PHP 9 is coming and provides a great opportunity. I also like the idea from Pierre to provide interfaces. Some people prefer an explicit method call over an operator doing magic things, which I fully understand. Perhaps we could allow both? Regards, Dik