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
true
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?
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.