Dispatch ambiguity can really bite you, particularly if you start extending methods from other packages. An issue I often run into at the same time as method ambiguity is a stack overflow from self-calling constructors. If you try to define an outer constructor with default arguments, it's really easy to end up just calling that constructor from itself.
The metaprogramming trick for defining a set of methods at once is useful, but I wish there were a more compiler-level solution to sorting out ambiguities or determining what's more "specialized".
These don't really color my view on multiple dispatch, however. I find it to be a really useful tool and I don't run into dispatch issues very frequently. If you're meticulous about your typing it's usually easy to avoid these pitfalls, but sometimes they still crop up.
It does catch method ambiguities like those shown in this blog post:
julia> using JET
julia> f(x, y::Int) = x + y
f (generic function with 2 methods)
julia> f(x::Int, y) = x - y
f (generic function with 2 methods)
julia> g(x, y) = f(x, y)
g (generic function with 1 method)
julia> @test_call g(1, 2)
JET-test failed at REPL[13]:1
Expression: #= REPL[13]:1 =# JET.@test_call g(1, 2)
═════ 1 possible error found ═════
┌ @ REPL[12]:1 Main.f(x, y)
│ no matching method found for call signature (Tuple{typeof(f), Int64, Int64}): Main.f(x::Int64, y::Int64)
└──────────────
ERROR: There was an error during testing
method overloading is a horrible language feature that papers over the absence of other, more useful language features like optional arguments, etc.
i worked on a JVM programming language back in the day, and that damned feature screwed up everything: method resolution was obviously a pain, but it got involved in generics, class compatibility, it even ends up worming its way into bytecode, since methods names are really the name plus the fully qualified type name of every argument (even if there isn't any method overloading for a given method, just awful)
It might be annoying to implement well, but there's a reason no widely used programming languages (other than assembly) have add_int and add_float as separate functions.
I don't know GScript, but wouldn't it be enough to know which methods are declared in GScript (and not allow overloading for these)? Then type inference can work fully most of the time and only give up when calling non-Java code.
Also, why does this complicate the parser? It looks like you're interfering some type information from later usage (the `foo( someVar )` example), so handling typing in the parser seems a bit strange.
As for the bytecode, it's not just methods: Fields likewise are identified by name and type and can be overloaded. I'm just happy that Java itself doesn't allow field overloading - I'm not the biggest fan of method overloading either.
Multiple dispatch with external methods isn't a 'feature' of Julia, it is the central organizing principle that the whole language is built on. And among everyone who actually uses the language there is consensus that it is what makes it good.
Sorry to hear that you failed to implement it back in the day, but that doesn't mean there's anything wrong with multiple dispatch in and of itself. It's just hard to get right. But when it works, it is without doubt the best paradigm for a language that I can think of.
BTW, optional arguments are not 'absent' in Julia, they are absolutely present, and are, in fact, implemented using multiple dispatch.
The metaprogramming trick for defining a set of methods at once is useful, but I wish there were a more compiler-level solution to sorting out ambiguities or determining what's more "specialized".
These don't really color my view on multiple dispatch, however. I find it to be a really useful tool and I don't run into dispatch issues very frequently. If you're meticulous about your typing it's usually easy to avoid these pitfalls, but sometimes they still crop up.
https://github.com/aviatesk/JET.jl
It does catch method ambiguities like those shown in this blog post:
i worked on a JVM programming language back in the day, and that damned feature screwed up everything: method resolution was obviously a pain, but it got involved in generics, class compatibility, it even ends up worming its way into bytecode, since methods names are really the name plus the fully qualified type name of every argument (even if there isn't any method overloading for a given method, just awful)
i wrote an old blog post on this:
https://guidewiredevelopment.wordpress.com/2009/05/22/i-am-h...
in conclusion: things should have unique names
Also, why does this complicate the parser? It looks like you're interfering some type information from later usage (the `foo( someVar )` example), so handling typing in the parser seems a bit strange.
As for the bytecode, it's not just methods: Fields likewise are identified by name and type and can be overloaded. I'm just happy that Java itself doesn't allow field overloading - I'm not the biggest fan of method overloading either.
just an awful feature that solves no problems that can't be better done with other features that, for whatever reason, just aren't as popular
Sorry to hear that you failed to implement it back in the day, but that doesn't mean there's anything wrong with multiple dispatch in and of itself. It's just hard to get right. But when it works, it is without doubt the best paradigm for a language that I can think of.
BTW, optional arguments are not 'absent' in Julia, they are absolutely present, and are, in fact, implemented using multiple dispatch.
i'm shocked it's still up, tbh