The Options package was developed before keywords existed. On Thu, Oct 9, 2014 at 4:02 PM, Andrei Berceanu <[email protected]> wrote:
> Tim, what do you mean by "people have moved away from it now that we have > keywords"? In my example I do use keywords (in fact that is the only thing > I use), notice the ";" at the begining of each function argument list. > > //A > > > On Thursday, October 9, 2014 9:33:00 PM UTC+2, Tim Holy wrote: >> >> While people have moved away from it now that we have keywords (for some >> good >> reasons), the Options.jl package might be worth a look in this specific >> case. >> >> --Tim >> >> On Thursday, October 09, 2014 03:14:52 PM Stefan Karpinski wrote: >> > Yes, this is a major problem, but I'm not sure what the fix is. It's a >> > serious language design issue and I'm not aware of any languages that >> have >> > good solutions. >> > >> > On Thu, Oct 9, 2014 at 3:09 PM, Andrei Berceanu <[email protected]> >> > >> > wrote: >> > > 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 >> >>
