Open
Description
It would be useful to have an isconstant
function or macro which returns true if the input is a constant, otherwise returns false. What do I mean by "constant"? I mean that if v
is not a constant, then somefunc(Val(v))
will trigger a dynamic dispatch, otherwise it won't.
Having such a function/macro would enable at least two useful things:
- Compile-time branch to faster code if a value is constant. See this example.
- Make constant propagation regressions in core Julia easy to detect in unit tests.