i asked a similar question a while back julialang: can (should) this type error be caught at compile time?, and i would like to pose a related question.
function somefun()
for i = 1:10e10; sin(i); end # a time-consuming loop
nonexist_fun() # call to a non existing function => error
end
here a non existing function nonexist_fun()
is called and causes an error. unfortunately the error is only discovered at run-time, after spending a long time executing some previous instructions inside somefun()
, not at "parse-time".
question:
could and should this be discovered at a preliminary "parse-time" pass?
if such a "parse-time" option exists, how to apply it?
otherwise, what is the recommended workflow, to detect and/or prevent this kind of error ahead of runtime, where the program may explode only after already having wasted a long time executing?
thanks