4 ms·
From playing a bit with the Julia REPL (http://forio.com/julia/repl/ http://forio.com/julia/repl/), it seems that the dispatch of the method is dynamic, as oppo
by epidemian 12y ago
From playing a bit with the Julia REPL (http://forio.com/julia/repl/ http://forio.com/julia/repl/), it seems that the dispatch of the method is dynamic, as opposed to the dispatch of overloaded functions in C++:
julia> function foo(s::String) "$(s)!!!" end
foo (generic function with 1 method)
julia> function foo(n::Int) n + 1 end
foo (generic function with 2 methods)
julia> foo(rand() < 0.5 ? "Hello" : 41)
42
I'm not used to this kind of dispatch for bare functions, but it seems to me that it could offer similar capabilities to what subtype polymorphism provides in OO†, without having to define new types for this methods to live in or polluting the existing types.
† Probably more, as the dispatch can be resolved based on many arguments.
- deleted 12y ago[deleted]