Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115773 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 68421 invoked from network); 23 Aug 2021 13:03:38 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Aug 2021 13:03:38 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 27E011804B3 for ; Mon, 23 Aug 2021 06:37:18 -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 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-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (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 ; Mon, 23 Aug 2021 06:37:17 -0700 (PDT) Received: by mail-lj1-f177.google.com with SMTP id c12so31605559ljr.5 for ; Mon, 23 Aug 2021 06:37:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=sDcqnH/Bw3NpjgtwW7s/5N9L5eK+iwNzbwb64MAOmrI=; b=AqPITZCBEenVaJ0JY4WjDBRacSuzC+7rI+gQQritHAGD0xxduHLUEBR6xWHwQNZLXt +OST0MtYw5P0YEgumyGm3oCZ0txRyy4cCqWFZwVirBfqDBYl8i1uPeKqngnxpZM8HNuz qG2p1F8pL0Wkh4EPdBWfAXg/OwqUejRJ6X68ax+af55ZHQb0gCCIIiLsOqHq15q6uzL5 AdLW5QK58XVDPYef7IsXXF8TdWfe6kuKK3kyOmwT3ATWQHU/kJcJV1YLoeQHtshyiev3 O4djHugJ6um8Ttz6BA0V5ESOiml6GXnxRoI9B3JL7xYJusywPXZDBDP8xIxAp5fEeNKz ntfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=sDcqnH/Bw3NpjgtwW7s/5N9L5eK+iwNzbwb64MAOmrI=; b=ESC+Vb4GwFoGlgI6vJkT9KhggDLuayHek8Re24XCNPU4haAc2ycPqmBf2D4+T464t6 JsKD43VNH7Ohc+AG2NKQwGrLe1kppE8DYoOm9K26CB4P5XRhV7v9fxgIZKFfj7nFRIDz uORpmds+w5/NydJZwSmzhM6y7O/qKm0zlzVX+bq1sjf5xDHQTA3cS3aCN+nNkKz+z3n3 NTifjJXXFq0tbHy/Wb8x7WQtUEBLzNNngx65AB3zWX6P3157Rl/NEYjCaOVUfWO9gcYB fPsEq7CEV3p/TYbT+RVnvsWCaggn8sBLc7ybAqkznmEfAW2oHPOzSwS1DzG1VzWWhLrw 0DXw== X-Gm-Message-State: AOAM53145HH3Bn/Jj9rmYY6OQ8qhnuAZbODg0yYWdyuqIt3+GY+/K9m0 5TbhjoKgNeVgl2TETe24JPcAHF0nG95SDE3n7MefES3Iz8BLvA== X-Google-Smtp-Source: ABdhPJxKn3id10CnNd8J7MILiqLd2ByRbmuPlv9rqw4vzRFBRJvOh10WnIlVrI5Txx9fgNdlgvRBJ2kLzK+PKRDGG4M= X-Received: by 2002:a2e:97cb:: with SMTP id m11mr5048323ljj.240.1629725835540; Mon, 23 Aug 2021 06:37:15 -0700 (PDT) MIME-Version: 1.0 References: <2fd2d665-ca3a-4fa8-9196-6c8b1b2a3da0@www.fastmail.com> In-Reply-To: Date: Mon, 23 Aug 2021 06:37:00 -0700 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="000000000000823feb05ca3a1d91" Subject: Re: [PHP-DEV] [RFC] User Defined Operator Overloads From: jordan.ledoux@gmail.com (Jordan LeDoux) --000000000000823feb05ca3a1d91 Content-Type: text/plain; charset="UTF-8" Pierre and Dik, The thread you were replying to is older and doesn't reference the current RFC: https://wiki.php.net/rfc/user_defined_operator_overloads This is the current discussion thread for the RFC. In particular, I'd encourage reading about which operators are supported, the restrictions on the implementations, and the failure mode behavior. Pierre: > and hell, if "->" doesn't mean "access that object member" anymore, but "hey, the implementor could do anything at all instead", sky will fall upon us. I hate to break it to you, but __call and __get already do this, and aren't even a part of this RFC. I'd highly encourage you to read what operators are supported and how, because this RFC definitely does not suggest opening ALL operators to overloads. There are very deliberate omissions. However, the object accessor `->` is already overloadable to some extent with `__call` and `__get`. The scope resolution operator `::` is already overloadable to some extent with `__callStatic`. The string concatenation operator `.` is already overloadable to some extent with `__toString`. The **assignment operator** `=` is already overloadable to some extent with `__set`. These all have limitations in how they are called automatically however. For instance, `__set` doesn't allow arbitrary overloading of the assignment operator, instead it requires the left side to reference a class property. Similar sorts of restrictions are proposed here. The fact that the reassignment operators *must* be supported by any overload will very highly discourage non-immutable implementations. The `__equals` overload must return a bool. The `__compareTo` overload must return an int and will have its return values automatically normalized to -1, 0, 1. The RFC document covers a lot of detail about the proposed implementation and addresses many of the things you brought up. Jordan --000000000000823feb05ca3a1d91--