Re: [VOTE] Userspace operator overloading

From: Date: Sat, 28 Mar 2020 21:21:27 +0000
Subject: Re: [VOTE] Userspace operator overloading
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-109404@lists.php.net to get a copy of this message
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

« previous php.internals (#109404) next »