can record domain updates ocaml generalized?
i'm unequivocally amateur ocaml programmer greatfully atonement me stupid/obvious question. there's a lot locate i competence have missed documentation.
i have bottom formula that's starting feeling this:
let update_x p x =
add_delta p;
p.x <- x;
modernise p
let update_y p y =
add_delta p;
p.y <- y;
modernise p
let update_z p z =
add_delta p;
p.z <- z;
modernise p
the duplication starting bug me since i want something this:
let update_scalar p scalar value =
add_delta p;
magic_reflection (p, scalar) <- value;
modernise p
this proceed i transform x i simply call:
update_scalar p 'x' value
this calls out "macros!" me nonetheless i don't trust ocaml macro system. else i do?
Comments
Post a Comment