To do this in C++ I would overload `operator()` you can do the same in Nim {.experimental: "callOperator".} type Function* = object proc `()`*(f: Function, i: int): Function = ## do your logic here var f: Function f = f(1) f = f(2) Run
If you don't want to use experimental features you could call this something else.