I purposefully didn’t use ternaries because the original Fortran example had cases with multiple statements. Sure you could use begin ... end
there, but it erases any cleanliness benefits.
I haven’t verified whether your snippet or any of the ones below generate a switch, but I don’t have to either! Anyone can easily check for one just by using @code_llvm
. To confirm an actual jump table is being generated (which, again, I could get neither the Julia compiler or GFortran to do), simply use @code_native
and check for this this kind of pattern.