To reinforce Yichao's point, using Nullables in the way you propose comes 
with substantial performance risks. The problem is that your strategy 
globally poisons type inference: type-uncertain functions don't just force 
run-time dispatch near the location of their function calls, they also 
force run-time dispatch in every downstream function call that depends upon 
the results of that function call.

Consider code like the following:

function slow()
    x = uncertain_type_generator()
    for i in 1:10_000_000
        do_something_with(x)

    end
end


Every call to do_something_with() is made type-uncertain because the type 
of x can't be inferred at method-compile-time. So your hot loop is poisoned 
by the use of a once-called type-uncertain function.

 -- John

Reply via email to