Re: [RFC] Userspace operator overloading

From: Date: Sun, 16 Feb 2020 01:54:21 +0000
Subject: Re: [RFC] Userspace operator overloading
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-108614@lists.php.net to get a copy of this message
On 15 February 2020 22:05:52 GMT+00:00, jan.h.boehmer@gmx.de wrote: >Some discussion points, I can think of, would be the naming of the >methods >(maybe naming them after the operator symbol and not the arithmetical >operation they represent, e.g. __plus instead of __add) or putting the >methods inside of interfaces like done for ArrayAccess As I mentioned earlier [1] I think the answers to both of these questions depend on a fundamental philosophical question about what you're overloading: - The groups of operations which exist for built-in types e.g. the arithmetic operations overloaded by GMP; or string operations overloaded by an object with enhanced Unicode functionality. - The individual symbolic operators, with no intrinsic meaning - e.g. overloading . for concatenation on strings but dot-product for vectors; or a DSL overloading << and >> for "into" and "out of". I think it would benefit the RFC to take a stance on that question, and build the feature around it. [1] https://news-web.php.net/php.internals/108347 -- Rowan Tommins [IMSoP]

« previous php.internals (#108614) next »