What is the context? If you have a tuple of arguments, you can just do g(args; kws...) = f(args...; kws...). What actual problem are you trying to solve here?
In the thread you linked, the poster was storing arguments as strings, which is generally a bad idea for many reasons.
Just a utility function in jupyter to output a title:
function title( txt; sz=25,color="blue",justify="left")
t = """<br><div style="width:30cm;color:$(color);text-align:$(justify);font-size:$(sz)px;">$(txt)</div>"""
display(HTML(t))
end
The issue was that adding a substring forces calling the function with the title including some html
(e.g., <p style="…>). I wanted to make it easy on myself and the users of my notebooks
by rewriting the function to take some kind of simple structure that allows multiple instances of text,
with only some of the default arguments being overridden.
Not valid code, but something resembling: title( ["A title", ("subtitle", sz=15)] )
The reason I mentioned folding is that the function would concatenate appropriate html substrings
struct T
txt ::String
color ::String
justify ::String
sz ::Int
height ::Int
f
end
T(txt;sz=20,color="blue",justify="left",height=5) =
T(txt,color,justify,sz,height,()-> "<p style=\"color:$color;font-size:$(sz)pt;height:$(height)px;text-align:$justify;\">$txt</p>")
title( s :: T) = display(HTML("<div>"* s.f()*"</div>"))
title( txt :: String; sz=25,color="blue",justify="left",height=5) = title( T(txt,sz=sz,color=color,justify=justify,height=height))
title( l :: Array{T} ) = display(HTML("<div>"* reduce( (x,y)->x.f()*y.f(), l )*"</div>"))
It can be called with statements like
title( T("Some text",sz=20) ) # single line output using T()
title( "="^300,sz=3) # single line output
title([ T("s",height=5,sz=25,color="magenta"),
T("x",sz=15,height=10)]) # multiline output
Still clumsy to use! Is there any way to get rid of the constructor for T? Or better Julia code?