November 2017
Beginner
316 pages
6h 40m
English
Imagine you are creating your own type with some random field num in it. You can easily fall into doing this:
julia> struct SampleType
num
end
This will allow num to take any type, and mark the beginning of some unwanted type mismatch errors too! However, from the compiler's perspective, this is bad as it will not be possible to extract more information from the object itself, which results in poor code performance:
julia> α = SampleType("stringvalue")
SampleType("stringvalue")
julia> β = SampleType(10)
SampleType(10)
julia> γ = SampleType(10.0)
SampleType(10.0)
What do you see? Well here, all the three variables are valid and make sense to the compiler, but which one would you choose (if you wrote the code targeted ...
Read now
Unlock full access