"dinamically" addressing an input closure

Hi everyone,
first post here
i’m trying to write a simple “switch” in OSL and I need a way to dinamically select which input closure will be directed to the output socket

obviously i could do with a series of if statements but i would like a way to parse a string (“InputSlot”+number indicating the name of the input socket) to the actual closure in order to assign it to the output, something like


shader node_switch (
int whichSlot = 0,
closure color InputSlot0 = 0,
closure color InputSlot1 = 0,
closure color InputSlot2 = 0,
closure color InputSlot3 = 0,
output closure color OutputSlot = 0
)

{
OutputSlot = <i>parse </i>("InputSlot"+whichSlot);
}

being the “parse” the function i’m looking for

any ideas? (thanks in advance)

A.