Interpreting @trace dynamic dispatch warning on apply_type

New to Julia, and I am trying to build good habits for writing functions. To that end I am applying the Traceur.trace macro to some of my functions and seeing what happens. Here’s an example I don’t understand. When I run

julia> biasedcoin(p::Float64) = rand(Float64) <= p
julia> @trace biasedcoin(0.5)
┌ Warning: dynamic dispatch to ((Core.apply_type)(Base.Val, x))()
└ @ essentials.jl:683

This is in Julia Version 1.0.3 (2018-12-18) (intalled using JuliaPro)

Not sure what this means or if there’s anything to do about it. Any idea where to learn more?

This is within rand:

julia> @trace rand()
┌ Warning: dynamic dispatch to ((Core.apply_type)(Base.Val, x))()
└ @ essentials.jl:728

So it is not your fault (but I’m not sure whether it is a problem with rand or a false positive).

A side note: whilst it is good to write type-stable functions for performance critical bits, it is also good (and productive) that in Julia you can write non-type-stable functions for the less critical parts. Just separate the two with a function barrier.

Have fun with Julia!

1 Like

Thanks for helping and showing me a good a way to identify the source of the warning.

I am looking forward using Julia in a full sized application where I can explore its full range of features.

1 Like