Re: function overloading
| From: | Rowan Collins | Date: | Thu, 17 Nov 2016 11:02:06 +0000 |
| Subject: | Re: function overloading | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-96945@lists.php.net to get a copy of this message | ||
On 16/11/2016 09:32, Quim Calpe wrote:
class EventHandler {
public function handle(Event $event) {
if ($event instanceof ProductCreated) {
...
} elseif ($event instanceof ProductNameChanged) {
...
}
}
}
I don't see much wrong with this; the intent is very clear. I think there's a general aversion to instanceof checks as somehow not "pure" structure, but sometimes anything cleverer would just be over-engineering.
That's not to say that there are zero use cases for function overloading in a dynamic language, but I don't think there are that many.
Regards,
--
Rowan Collins
[IMSoP]