re: Why self is not this in Python! VIEW POST

re: Sure, let me demonstrate: Multiple dispatch function (x:Person, y:Animal) function (x:Person, y:Person) function (x:Person, y:Person) f...

I never experienced this kind of pain and I'm using Next Generation Shell (with multiple dispatch) for years now.

function (x:Person, y:Animal, z: Integer = 0)
function (x:Person, y:Person, z: Integer = 0)
function (x:Person, y:Person, z: Integer = 0)
function (x:Animal, y:Animal, z: Integer = 0)

Any function that does use the z parameter - I don't see neither a problem with adding parameter nor a way around that. (Am I missing something here?).

Any function that does not use the z parameter - there is no need to add it, at least in NGS.

If NGS allows default arguments, then it may be OK. Julia, as far as I know, uses multiple dispatch and its users are happy. Recently, I run into a nasty problem with an overloaded method in C#, where I had to supply an argument I did not care for because the overloading did not cover my use case.

Still, I am not convinced that multiple dispatch is a good design for a modern language. But I may be wrong, of course. The language I have on my mind differs heavily from everything I've seen so far.

I took the example from wiki and thinking about it, even the example itself is crippled and code smell on its own. Actually, instead of using signature with types, much simpler and more correct would be just to rely on interfaces or traits.

So instead

function(x: Animal, y:Person, z: integer)

Would be just one

function(x: CommonTraitForAnimalAndPerson, y: CommonTraitForAnimalAndPerson, z: integer)

This one is actually more concise and general than any previous solution.

code of conduct - report abuse