Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116700 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 45061 invoked from network); 21 Dec 2021 12:02:59 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 21 Dec 2021 12:02:59 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5E2E11804B5 for ; Tue, 21 Dec 2021 05:06:40 -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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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-ua1-f51.google.com (mail-ua1-f51.google.com [209.85.222.51]) (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 05:06:39 -0800 (PST) Received: by mail-ua1-f51.google.com with SMTP id o1so23560609uap.4 for ; Tue, 21 Dec 2021 05:06:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dqxtech-net.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=UbAUPb1zCP+44wSDy3WNbtMfwKXhQ06VcJK0z/TzWRA=; b=MoLFiWkXmB9Oy9tc2Wm4rUJgf9VS6klyvyy5vJzfN15cCIdCkTger4am0Ixiu69tYa nQOFTszWKRaLCibLsUzXibf6pykRP+LwTgbTLtwFQkwUcvSTP7S4kXHHp1EVDl7oAi8W 2Zj7758Of4KronsyXIYO0bFv75P5mQ5N8/+Mw2nWjeUReXPd/9n05g27HFk+dR8hz053 0n4q4HojpQhMAMA1ElcC9tzf8uiG0oW7Vxpe45szlqyRc/jO32N+/CQyrcy7p95EbYzO ZYb3+iHLPHz/SB+C0c8+uEKy4k5aRb4mknyD2symjTUKkwh08Hw/PT18qyZ5Vmh2X+vW 9WLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=UbAUPb1zCP+44wSDy3WNbtMfwKXhQ06VcJK0z/TzWRA=; b=vec8GwjI2wV/agtZaKaRTz2iRlhIBwc3QPV/RbISHVlweKGbmkJoYvcyL60BqsIsL5 j/H/kPbi2S10hoWb7lqpRrmWNlEZIOezKDMGdjA7EhImOM8RB5xuRMpFYKmcyD6fnCd4 aA25IzsP1M9kEE9jIhJM69yddiRgH7W02T9jR5+VprpcYB6sVDXzwBQOXtztzJQG5krW cnTl+f1rHNoMVybWSefy2IgQS5JmJSPaliANp0MSPmYKJan17fELr3Uv0f5/ncfq5CYa ocy2hTi3FU9PxkzntqhvdBGh15GjE+gvtahRJdrg+MHHY/ctK6CgquYxERec3bPFbfwo xzQw== X-Gm-Message-State: AOAM530JWNdaSnFL6Mi3cjwWD+Jnb9J+mnRlaIaiJPF5XUP7wQIdahGQ GaqGd1iqs4sO+KZKViGwV797nMy/YnJ7mPiAsHGCViRqWE2g1Wwf X-Google-Smtp-Source: ABdhPJxeFkBuc0+YUHPKalBuyJaaBuQO8DpRz46sStTFtKIQny8GoexNtztmFWmBxTp7r9uUo7GWRBHlJHdofVsCt4A= X-Received: by 2002:ab0:3009:: with SMTP id f9mr1115899ual.4.1640091998854; Tue, 21 Dec 2021 05:06:38 -0800 (PST) MIME-Version: 1.0 References: <44b3fb4b-4693-1639-c8c0-5e17296c196e@gmail.com> <4b58c011-ed87-ba87-201d-0cf8e4116c6f@processus.org> <67431363-cd1e-9575-7d51-0f4d265d05b9@gmail.com> <7285dd63-42f4-dcd1-6549-178157858abd@gmail.com> In-Reply-To: <7285dd63-42f4-dcd1-6549-178157858abd@gmail.com> Date: Tue, 21 Dec 2021 14:06:27 +0100 Message-ID: To: Rowan Tommins Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC] User Defined Operator Overloads (v0.6) From: andreas@dqxtech.net (Andreas Hennings) On Tue, 21 Dec 2021 at 10:13, Rowan Tommins wrote: > > 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. Wow, you are right. I should read more before I post. Thank you Rowan! Sorry everybody for the distraction. > > So the questions you posed are not hypothetical: Indeed. The "concern" already applies for those extension-provided operator overloads. > > > - 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. Well the initial values could be scalar or GMP. As soon as we hit any gmp_*() function, the return type is going to be GMP. In the rewritten example using mostly operators, the gmp_invert() is the only part that guarantees the return type to be GMP. Without that gmp_invert(), the return value could as well be scalar, if all initial variables are. float|GMP * float|GMP = float|GMP gmp_mul(float|GMP, float|GMP) = GMP > > The only difference is that right now, you can only overload operators > in an extension, not in userland code. So the same "concern" already applies here, But it can be outweighed by the benefit. > > Regards, > > -- > Rowan Tommins > [IMSoP] > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php >