I often find myself passing long lists of parameters from one function to 
another. A simple, contrived example would be the following











*function fun3(; kw1 = 1, kw2 = 2, kw5 = 8, kw6 = 4)    fun2(; kw1 = kw1, 
kw2 = kw2)endfunction fun2(; kw1 = 1, kw2 = 2)    fun1(; kw1 = kw1, kw2 = 
kw2)endfunction fun1(; kw1 = 1, kw2 = 2, kw3 = 3)    kw1 + kw2 + kw3end*This 
results in code which is not easy to maintain. Notice that kw1 and kw2 are 
common to all 3 functions. Is there a way to pass the two of them (or 
more!) automatically? The way the code is written now, if I decide I want 
kw3 of fun1 to be changeable from fun3, I need to change the code in 
various places (in bold) -- very bug prone:

*function fun3(; kw1 = 1, kw2 = 2, kw5 = 8, kw6 = 4*
*, kw3=3)    fun2(; kw1 = kw1, kw2 = kw2*







*, kw3=kw3)endfunction fun2(; kw1 = 1, kw2 = 2, kw3=3)    fun1(; kw1 = kw1, 
kw2 = kw2, kw3=kw3)endfunction fun1(; kw1 = 1, kw2 = 2, kw3 = 3)    kw1 + 
kw2 + kw3end*
Tnx,
//A

Reply via email to