I'm seeking a way to call an awk
function by name, i.e. by using a string that is user input.
My goal is to replace a lot of code like this...
if (text == "a") a(x)
if (text == "b") b(x)
if (text == "c") c(x)
... with any kind of way to dispatch to the function by using the string name something like this:
send(text, x)
In other languages, this kind of effect is sometimes described as reflection, or message sending, or dynamic dispatch, or getting a function pointer by name.
I'm looking for a way to do this using gawk
and ideally also using POSIX portable awk
.