3 ms·
Not sure about the example semantics, but with MyDef (https://github.com/hzhou/MyDef https://github.com/hzhou/MyDef), it is trivial -- $call value_ops, val
by hzhou321 5y ago
Not sure about the example semantics, but with MyDef (https://github.com/hzhou/MyDef https://github.com/hzhou/MyDef), it is trivial --
$call value_ops, val, operate, operate
subcode: value_ops(v, @ops)
type_t $(v) = allocate();
$(for:op in $(ops))
type_t tmp$(_i) = operate($(v));
$(set-1:v=tmp$(_i))
destroy($(v))
MyDef is a general purpose preprocessor.
EDIT: maybe this is more fit what was intended
type_t var;
$(for:op in allocate, operate, operate, destroy)
var = $(op)(var);