Hi Pavel, > On 12 Feb 2015, at 13:48, Pavel Kouřil <pajou...@gmail.com> wrote: > > C# does have dynamic typing.
No it doesn’t, it’s a statically-typed language. I don’t understand why you say it has dynamic typing - there is some limited dynamism in parts, but I don’t think it affects what we’re talking about. Dynamic typing and polymorphism aren’t the same. > I just don't believe that method overloading would suddenly make > everyone write poor programs. Maybe not, but all the facilities needed to make good programs are already there. Overloading would only really be useful for writing bad programs, because all the good things it enables are already supported by PHP. > It brings cleaner declarations of methods and functions. Only slightly. A switch() (or better, a pattern match, were we to add that) can do the same job and it’s not that much less clean. > Also, it > brings the possibility of having operator overloading in user classes > someday in the future (yes, this can be abused as well, but it also > has legitimate use cases - like class for representing Money and being > able to do +, - , / or * operations on them). Overloading isn’t necessary for operator overloading. > Is the option of omiting > type hints and having optional parameters really a good enough > replacement for method overloading polymorphism for you? Because for > me, it unfortunately is not. :( Could you give an example use-case? > Read the example once more, please - the issue I see with it is that > bar() requires float, but foo() just number and doesn't convert it to > the required type. The most unpredictable thing is that it will work > half of the time and half of the time it will just throw errors. Well, yes. PHP is dynamically-typed, this can happen, whether you’re using strict or weak typing. Your only way to guard against it here is to do proper testing. Well, if we added a numeric type hint, your IDE could catch this error for you, actually. Anyway, the same thing can happen for float->int conversions *with* weak typing, as we disallow certain conversions (PHP_INT_MIN > $x, PHP_INT_MAX < $x, !isfinite($x), isnan($x)). Also, even though PHP does allow most float->int conversions with weak typing, it doesn’t mean they’re a good idea. Silently losing the fractional part is probably not what you want. Thanks. -- Andrea Faulds http://ajf.me/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php