Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121456 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 6925 invoked from network); 24 Oct 2023 12:57:59 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 24 Oct 2023 12:57:59 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 496961804BC for ; Tue, 24 Oct 2023 05:57:59 -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-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (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 ; Tue, 24 Oct 2023 05:57:58 -0700 (PDT) Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-32d9b507b00so3251378f8f.1 for ; Tue, 24 Oct 2023 05:57:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698152277; x=1698757077; darn=lists.php.net; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=qpW4ATr3D/WMlcs9ow16I1bI8v92gvVu58UVQbO2tjk=; b=F9Du2t89qZvNWEb3Ou/fWuta25yFdddqgKvWXPWn3I96PDepYNsHCneTvDdFFRdHhH 44hKcuTYUhbth2v03CYXQ+8jNy2tonbI1G8QmsltVyIFUEzSRVzHvGLxDEJYFg+ZpxMk bwprkwEZnMTE7xmLfIOvVrglniHA0xmlDDZYAhnZ07tz0KY047FaUv4g+b5NCWeTQn8A cLlRV4JuiFB/Kn8J2qF99QqOQZmMqYMuyC4m1iAZQHBIM/e8DUttGvl5OgaZEUrb4JmA hoTQ3ptQwC36Y5EuO7rgPb700YmhRs71+3nhjp49saAsU44LVlZYFyHLAr6D14WfzME4 EaWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698152277; x=1698757077; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qpW4ATr3D/WMlcs9ow16I1bI8v92gvVu58UVQbO2tjk=; b=GZXyFm5NuShY3IUQAKqaDiGna725QJ3ye+bTulon+Mjj9kcXeMNKJTRvgtHvGbAJ4g oTnSsaPoguLFVf5Huo4Z6NTs+OUMB3LmTGIUA4YMF86bs3F9KUgSuJtsUHqrJL2fdUbz s+JSllha9P1lhextXXSfhw0XqOpj+T/kasB02wwR3Q63LwDnpMA8nx3aEWnnw4HmA/xe 8DXPfkPAr8kyLfuqkTUwBDn6aSZm6cb56DHcxFXffcueZyLTLVKu1HPMzDqwIEej4obU qHiXRtHOelJ8lutpc85mqLeIq+uhEoe+6u3nf0Mxhncnr2WHUyiJYJY6oZcihih+4nqL eH5w== X-Gm-Message-State: AOJu0YyZDMbANlItMnJ/eVcN+QB19LErpw+1vZOA4iSi9osyv98Fyp+h GhJjGQI4tuqwUnpbM5pa0FNnixIM1nA= X-Google-Smtp-Source: AGHT+IE0tSPlVKr6UxN3tRbeUquseozgxtbJq/nasbetEBSjWetg6gCPhu7HBgf3GuYAvWoWKIhagg== X-Received: by 2002:a5d:410f:0:b0:32d:8185:9c15 with SMTP id l15-20020a5d410f000000b0032d81859c15mr8642452wrp.49.1698152277151; Tue, 24 Oct 2023 05:57:57 -0700 (PDT) Received: from ?IPV6:2a02:a45e:66ed:1:8355:ec0d:9c7a:47ec? (2a02-a45e-66ed-1-8355-ec0d-9c7a-47ec.fixed6.kpn.net. [2a02:a45e:66ed:1:8355:ec0d:9c7a:47ec]) by smtp.gmail.com with ESMTPSA id a3-20020a5d4d43000000b003196b1bb528sm9843645wru.64.2023.10.24.05.57.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 24 Oct 2023 05:57:56 -0700 (PDT) Message-ID: <52a295aa-ecfb-4b73-b288-b97ce4f7e9b6@gmail.com> Date: Tue, 24 Oct 2023 14:57:55 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Jordan LeDoux Cc: internals@lists.php.net References: <97e67da5-d54a-403d-be4d-ed275240442a@gmail.com> <53753a0f-04c2-442e-821b-20f107313a13@app.fastmail.com> 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 23-10-2023 22:07, Jordan LeDoux wrote: > I don't quite follow. The interface would cause the engine to use the > result of an `equals()` function on the object if it implements an > interface as part of `zend_compare`? Internally there is no `==` function, > there is only the equivalent of `<=>`. To implement it ONLY for `==` would > require a trapdoor of some kind in the `do_operation` handler that would > also affect the way the existing extensions work, such as the `DateTime` > class which implements a custom handler for the `compare` handler on the > zend class entry. No, the interface would not cause anything to happen in `zend_compare`. It would simply serve to make explicit that an object has a custom implementation of a (set of) operators and that the implementing method can be called directly. So the developer can choose to either use the operator or call the implementing method on the object. Both styles would be supported and the following two expressions would be equivalent: $a == $b $a->equals($b) (the method name is just an example) Regarding your (Jordan's) RFC on the subject: The method call style would not yield readable code in this case, as the 'methods' are named after the operators. So that part of the RFC would need to change to make both styles work. Regards, Dik