How do I make a dispatch table using multiple dispatch instead of Dict?

You can hoist everything into type space, as in

vrr(::Val{(0,0)}) = :ss
vrr(::Val{(0,1)}) = :sp
vrr(::Val{(1,0)}) = :ps
const KEYS = (Val((0,0)), Val((0,1)), Val((1,0)))
map(vrr, KEYS)

but it may be very taxing on the compiler, so it would be a solution of last resort for me.

I am still not sure I understand the context, but

  1. if you can decide this based on the type of a and c, just use the built-in dispatch of the language,
  2. if not, use branches (if).
3 Likes