You can put all the functions in a list, index into the list and call the function.
You should be able to put the functions in a struct and index into @typeInfo(impl).Struct.decls[i]. Also you could use a comptime [enum tag <-> function pointer] map, or compare @tagName against decls[i].name.
Although I personally can't think of any case right now where I'd not just use an enum plus a switch. It's a lot more straight-forward.
Maybe we'll have anonymous functions functions in the future. Perhaps then using a union(enum) of functions could be interesting, if only to avoid having to keep the enum, the action implementation and the matching code in sync.
For further actions, you may consider blocking this person and/or reporting abuse
You should be able to put the functions in a struct and index into
@typeInfo(impl).Struct.decls[i]
. Also you could use a comptime [enum tag <-> function pointer] map, or compare@tagName
againstdecls[i].name
.Although I personally can't think of any case right now where I'd not just use an enum plus a switch. It's a lot more straight-forward.
Maybe we'll have anonymous functions functions in the future. Perhaps then using a union(enum) of functions could be interesting, if only to avoid having to keep the enum, the action implementation and the matching code in sync.