>> Have a look at stagedfunction (v0.4). >> > I tried with the nightly build, but without success (using stagedfunction > instead of function) - however, it looks like it is the solution, maybe I > will just have to wait until this is implemented (and the syntax set).
You will need to adapt the code to work with stagedfunctions. They work in stages: with the types of the arguments the code for the actual function is produced. Sadly there is no documentation, I think. See: https://github.com/JuliaLang/julia/issues/7311 >> > The only other way (I can think of) to get this result would be to use >> > macros and enumerate the different possible types, but if somebody can >> > think of a better solution, thanks! >> >> why not write: >> type typeB1 <: typeB end >> type typeB2 <: typeB end >> compute(a::typeB, b::typeB) = return (a, b) >> > Because I would like to ensure that a and b are of the same type In that case use: compute{T<:typeB}(a::T, b::T) = return (a, b) T will be set to the concrete type of a and there will be a no-method error if isa(b,T) is not true.
