Hi,

2015-02-12 18:31 GMT+04:00 Andrea Faulds <a...@ajf.me>:

> 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.
>

 C# actually supports dynamic typing with a dynamic keyword [1]. But it
really doesn't mean that having method overloading in a dynamic language is
a good idea... C#, although it has a full ability to support dynamic
typing, is not usually used in this fashion. To understand why it's not the
best idea to use dynamic types with overloading you can just google "C#
dynamic type with overloading site:stackoverflow.com".

Another great deal in this question is performance, I think this subject
was brought up a plenty of times in this ML and it was pointed out a couple
of times that overloading even if doable at some point, would harm
performance of method calls, which are already one of the slowest (if not
the slowest) OPs in the engine. Languages like C# are usually able to
resolve method references at compile time (unless virtual methods are used,
even then it's only a matter of choosing right method from hierarchy not
from all the overloaded variants).

[1] https://msdn.microsoft.com/en-us/library/dd264736.aspx

Reply via email to