I'm new to Go and have limited experience on programming. I'm a hw engineer
but Go made me more intrested in sw.
My problem is to find a reasonable way to attack a problem. I want to
define calculation in runtime and use inside my code. Naturally will it be
slower than compiled code but thats ok for me.
I found a simple example in the funcmap from mikespook:
It maps a string to a func and make a call.
A bit more generic would be to allow a text input to be converted to some
data structure in a more complex scenario.
Example of a stupid input:
In general a function that can take functions,variables and constants as
inputs like a expression in a assignment in code. The set of available
functions and variables will be predefined.
My current thinking is to map input to tree datastructure representing the
hierarchy pointing out the function and its input in form of pointing to
next level of function below, variables and constants in any mix.At input
of textline should it be chect and a datastructure populated and then will
input be evaluated as call to function to evaluate according to
datastructure. Evaluation could maybe be based on funcmap above and when
input parameter is a function call for evaluation of that function in order
to evaluate the tree.
But i'm not sure if this approach is possible or if there are other better
ways to do it.