On 15/11/2016 16:13, Dominic Grostate wrote:
I think this may have been discussed before, but I was largely dismissed
because no one though it would be possible to implement.


My first thoughts are not to do with implementation, but impact on the rest of the language: language complexity, and performance.

First, having function overloading would undoubtedly make the language more complex; is this complexity warranted? If it is widely taken up, would it make the resulting code harder for new users to understand; if it isn't, is the effort of implementation and maintenance worth it?

Second, would the need to internally mangle function names and despatch by argument have a penalty for code that didn't make any use of it? I guess that could be mitigated if there was a declaration keyworded, like "overloaded function foo(int $bar) { ... }"; that way, a stub lookup for the unmangled name "foo" could indicate that this is an overloaded function, and trigger the more complex despatch logic with practically no overhead on the normal method. There's still going to be complexity though, for instance OpCache will need to know how to deal with it all.

These aren't reasons to throw out the idea though, just my initial thoughts on what we need to consider...

Regards,

--
Rowan Collins
[IMSoP]


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to