Is there any way to dispatch directly on a symbol function parameter? I have a function which takes a symbol and returns a different type based on a symbol that is passed into it. In order for this function to have a type stable output (whether explicitly or inferred), it would need to dispatch based on the symbol parameter. I realize this can be done with Val but I was hoping to avoid Val. I was hoping for something that look like this:
f( t::NamedTuple{T,U}, s::Symbol ) = t[s]
@code_warntype f((a=1,b=1.0), :a)
which returns a union. The undesirable but type stable Val version looks like this:
f( t::NamedTuple{T,U}, ::Val{V} ) = t[V]
@code_warntype f((:a=1,:b=1.0), Val(:a))