This is mostly for precompilation and library use. When compiling a shared library we can't rely on a runtime check if the compiler is not available (and trying to compile both branches is inefficient and might be impossible for the reason in the help section).
On Saturday, July 9, 2016, feza <[email protected]> wrote: > The docs read > > @static() > > Partially evaluates an expression at parse time. > > For example, @static is_windows() ? foo : bar will evaluateis_windows() and > insert either foo or bar into the expression. This is useful in cases > where a construct would be invalid on other platforms, such as a ccall to > a non-existent function. > > My understanding at a very top level is that julia code is first parsed, > macro expanded, then compiled. > > Now why is it important for this to be handled at parse time? I don't > really understand the following `This is useful in cases where a > construct would be invalid on other platforms, such as a ccall to a > non-existent function.` > > Why couldn't a simple > > ` if is_windows(); foo; else; bar; end ` > > work and why do we need @static? >
