2015-02-21 17:26 GMT-04:00 Pavel Kouřil <pajou...@gmail.com>:

> Hello,
>
> finally got to this, after a while of thinking - the first part was
> answered before, so I'll get only to the str_replace now. :)
>
> Basically, each of the 8 different version based on parameters does
> different thing, if I'm counting it correctly. So having 8 different
> declarations is IMHO valid. I know it sounds a little bit weird, but
> if you really realize the amount of things the function is doing based
> on the passed parameters, why would having one declaration with
> multiple argument types and if statements deciding what to do based on
> an argument types be better than 8 different declarations, where each
> one does one predictable thing and can be documented separately? :)
>
>
> PS: I know there's something like a declined RFC for method
> overloading in the wiki (actually, just a 7 years old email), but if
> there would be someone who would be interested in having method
> overloading in PHP and understands PHP's internals (I don't) so he'd
> be able to make the implementation, I'd like to discuss this idea with
> him more and contribute somehow to a possible RFC.
>
> Regards
> Pavel Kouril
>

I recently discovered this compact and lean implementation of PHP (ph7)
which has  overloading, scalar hinting and other nice features, so besides
hhvm it could serve as an inspiration for those working on RFC's

github.com/symisc/PH7

Would be nice to have function overloading on PHP now that theres going to
be scalar type hinting (luckily at some point), its the best a proven
approach to deal with different parameter types in a clean and
straightforward way. Also some functionality at the PHP C level (when
developing extensions) to register various overloads would be nice. When
working on the wxWidgets wrapper for PHP I had to mix all function/method
overloads into a single function which isn't too easy to do on an automated
way (github.com/wxphp/wxphp/blob/master/src/media.cpp#L170).

Also when working on an IDE like NetBeans it is a mess to supply an
interface file for auto-completion with methods/functions that have
different overloads. This kind of things may at first look like conflicting
with original PHP goals, but they are pretty useful once you understand
them.

Reply via email to