Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109404 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 92670 invoked from network); 28 Mar 2020 22:55:56 -0000 Received: from unknown (HELO localhost.localdomain) (76.75.200.58) by pb1.pair.com with SMTP; 28 Mar 2020 22:55:56 -0000 To: internals@lists.php.net References: <003701d6013c$9afe9750$d0fbc5f0$@gmx.de> <7a83f950a31d94d5ff2307ac8219db3b7b6482b6.camel@schlueters.de> <12ad7c71-8958-7742-12c4-e83e359c8186@gmx.de> Date: Sat, 28 Mar 2020 22:21:27 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Firefox/52.0 SeaMonkey/2.49.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 46.59.72.204 Subject: Re: [PHP-DEV] [VOTE] Userspace operator overloading From: ajf@ajf.me (Andrea Faulds) Message-ID: Hi, Christoph M. Becker wrote: > (frankly, I would not have not supported __concat() at all). Also, > overloaded operators should be programmed defensively, i.e. they should > not accept arbitrary arguments (how could that even work?), but only > those they can handle. If implementations adhere to these "rules", I > don't see real issues. Consider a type implementing some kind of list. Perhaps someone would want to overload the + operator to mean adding an item to the list. If the list accepts any type of value as a valid item, then you have an example of an unconditional overload. Regards, Andrea