table of functions vs switch in golang
问题 im am writing a simple emulator in go (should i? or should i go back to c?). anyway, i am fetching the instruction and decoding it. at this point i have a byte like 0x81, and i have to execute the right function. should i have something like this func (sys *cpu) eval() { switch opcode { case 0x80: sys.add(sys.b) case 0x81: sys.add(sys.c) etc } } or something like this var fnTable = []func(*cpu) { 0x80: func(sys *cpu) { sys.add(sys.b) }, 0x81: func(sys *cpu) { sys.add(sys.c) } } func (sys *cpu