We need the random name to ensure (probabilistically speaking) that the variables which need to be fixed because they are not sanitized, will have unique names.
The proposed solution that you suggested creates problems when the substitution of the not sanitized variables occurs.
Example:
Dataset array 1: _test
Dataset array 2: test0
Expression: _test + test0
Calculator: add _test
Original variable = _test
, Valid variable = test0
(this will pass because test0 has not been added yet)
Add test0
variable to the exprtk’s variable list (success)
Calculator: add test0
Original variable = test0, Valid Variable = test0
Add test0
variable to the exprtk’s variable list (failure, because the variable already exists)
We could pass original variables and valid variables and check for such cases in the generation of unique names, but we also would have to remove and re-add variables to the exprtk variable list.
Randomness is the only way that I can think of without making the code extremely convoluted.