First sorry for the thread's subject, but I don't know how to explain it well.
I have several functions that follow a pattern simular to this:
proc fname(sys:var System; param1:P1; param2:P2; .....; wp:Workplane; grp:Group):Whatever =
....
But once known sys, wp and grp, I would like to use: proc fname(param1:P1; param2:P2;...):Whatever.
What I would like to do is to fix those params. Something similar like closures but applying to several functions.
I was thinking about using a global for sys, and setting something default values for wp and grp. But I don't like it that much.
I was also thinking on templates or macros.
Is there any simpler approach that comes to your minds? Thanks
https://nim-lang.org/docs/manual.html#statements-and-expressions-using-statement
excerpt:
using
c: Context
n: Node
counter: int
proc foo(c, n) = ...
proc bar(c, n, counter) = ...
proc baz(c, n) = ...
proc mixedMode(c, n; x, y: int) =
# 'c' is inferred to be of the type 'Context'
# 'n' is inferred to be of the type 'Node'
# But 'x' and 'y' are of type 'int'.
Either with default parameters or overloading the function definition. Check the manual (https://nim-lang.org/docs/manual.html) for these.
My guess is you come from a dynamic language like python, ruby, javascript
You can use templates
template fname: untyped = fname(sys, p1, p2)