Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116695 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 28990 invoked from network); 21 Dec 2021 08:09:13 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 21 Dec 2021 08:09:13 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 373EA180511 for ; Tue, 21 Dec 2021 01:12:53 -0800 (PST) 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.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, 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-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 (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 21 Dec 2021 01:12:52 -0800 (PST) Received: by mail-wr1-f49.google.com with SMTP id d9so6002039wrb.0 for ; Tue, 21 Dec 2021 01:12:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=sekECRFUIhJbr1vbWszBvWFCYtQr6eURJVYDA1FnY2M=; b=qNVp3WGlfNUqsP0qvDlM8E7trVFF9SQ/U8OuN+ku4ndAywfEuOI6heJR17mgXubX7h m+mrrzImXy/ZlHq1W64+M/lbcpfT8ATs36tMWnCIP8ygtts4YXmIrxwEAN3fQerJDPLC IAriOozMBfnWluLe/K3ZqupFrsyyuoQ3NygmFjshfVI7tiLwsrEIhQ3ynlR0xfKbV/xb gpmW/fm0vxSIzwhVuPZfqQWVQu6H462XAtTUQIOOijSNwXEMUa+53e24rAlA2cjB20d3 Cb1ZjA2kfUjbY334I/nhUGdDcBdXDREBLCyojGcAG77jiuCx7LjjoF508QgH2hfpB4r6 M4iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=sekECRFUIhJbr1vbWszBvWFCYtQr6eURJVYDA1FnY2M=; b=BWYslkGoeGo6jfTDoFS+LZaTuXNVNn3VCU0XYcwi+Gr5jWoSalhyM/l8gGjjsg1fUs i1qnsH5L/a+IIpm1jL8k5fzdRvoHnRih+xINjhlE12hGvUxPvDopm3O9p05nxbnkFWdf dvntC+BSvtwaWRN1LUZ4J+1puT95AoBjzbVtF8/oou7CC8nBsi4+4bZ7om0vpL7weHAl gE3Ncai96seh2cMXQB1CEDH2x1pN3LeY3SaDDKh5RHzhxLUN0gZY6HoyxDYdU9QMV+xL ylJlK+Qti7PXY8KMIfyNIgmF5MY8C7RsprVN9gqDi5LFg1l8RLsTQpCIxPFTN7vCNUhm spWw== X-Gm-Message-State: AOAM532JYct7MwSxnpAP4Ml7WIFqgaVORjRCK5WcFDulQeYN9QEZe67z /WrIOU8bmrGGxKdkKYjNNMaBKNFJDIM= X-Google-Smtp-Source: ABdhPJzHCcKF8/kLUW7EXDVvhqf/JCbtnJ88n4iKWkg6dJJ++JgQC7gP6Z2elHsj2x6KvTp7Coe8GA== X-Received: by 2002:a5d:6787:: with SMTP id v7mr1867212wru.68.1640077971370; Tue, 21 Dec 2021 01:12:51 -0800 (PST) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id p5sm18468326wrd.13.2021.12.21.01.12.50 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Dec 2021 01:12:50 -0800 (PST) Message-ID: <7285dd63-42f4-dcd1-6549-178157858abd@gmail.com> Date: Tue, 21 Dec 2021 09:12:47 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Content-Language: en-GB To: internals@lists.php.net References: <44b3fb4b-4693-1639-c8c0-5e17296c196e@gmail.com> <4b58c011-ed87-ba87-201d-0cf8e4116c6f@processus.org> <67431363-cd1e-9575-7d51-0f4d265d05b9@gmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] User Defined Operator Overloads (v0.6) From: rowan.collins@gmail.com (Rowan Tommins) On 21/12/2021 00:43, Andreas Hennings wrote: > I think the example in the RFC is interesting, but not ideal to > advertise the RFC. > The example is with native scalar types and build-in operator implementations. > (I don't know how GMP works internally, but for an average user of PHP > it does not make sense to call this "overloaded") I think you have misunderstood the example. GMP doesn't work with scalar types, it works with its own objects; the general approach is to call gmp_init() with a string describing a large number that cannot be represented by a PHP integer. This gives you an object which doesn't have any methods (it replaced a resource in older versions), but can be used with the gmp_* functions, and with mathematical operators overloaded in the engine. So the questions you posed are not hypothetical: > - Are those variables scalar values, or objects? > - Are the operators using the built-in implementation or some custom > overloaded implementation? (depends on the operand types) > - Are the return values or intermediate values scalars or objects? They are objects, using an overloaded implementation of the operators, and returning more objects. The only difference is that right now, you can only overload operators in an extension, not in userland code. Regards, -- Rowan Tommins [IMSoP]