I am a very novice OCaml programmer, so please forgive me if this is a stupid / obvious question. There is a lot to learn, and I may have missed it in the documentation.
I have a base code that starts to look like this:
let update_x p x =
add_delta p;
p.x <- x;
refresh p
let update_y p y =
add_delta p;
p.y <- y;
refresh p
let update_z p z =
add_delta p;
p.z <- z;
refresh p
Duplicate starts to beat me because I want to write something like this:
let update_scalar p scalar value =
add_delta p;
magic_reflection (p, scalar) <- value;
refresh p
That way, when I update x, I can simply call:
update_scalar p 'x' value
This causes "macros!". for me, but I donβt think OCaml has a macro system. What else can I do?
source
share