We have the following function call used at multiple places within close proximity:
func(param1, param2, param3, param4, param5)
I would like to use
funccall()
in all the places.
Is there a notion of macros? Partials with all the arguments given (marked answer as correct) is correct and it works if all the subsequent calls are in the same scope.
What if the scenario is like this:
A():
func(p1,p2,p3,p4,p5) # 3 times
B():
func(p1,p2,p3,p4,p5) # 2 times
C():
func(p1,p2,p3,p4,p5) # 4 times
Using partial:
A():
funccall = partial(func,p1,p2,p3,p4,p5)
funccall() # 3 times
B():
funccall = partial(func,p1,p2,p3,p4,p5)
funccall() # 2 times
C():
funccall = partial(func,p1,p2,p3,p4,p5)
funccall() # 4 times
Ideal (if convention is followed in code and readability is not a problem)
macro funccall() = func(p1,p2,p3,p4,p5)
A():
funccall() # 3 times
B():
funccall() # 2 times
C():
funccall() # 4 times