hustf: curious... why are if-statements non-Julian? How would you do it? I think a macro-version would be best, and fairly easy to write
On Fri, Jan 8, 2016 at 12:55 PM, Josh Langsfeld <[email protected]> wrote: > Here's an idea for a more general and scalable approach rather than > checking each argument's type with an if-statement: > > function f(args...) > argdict = Dict(zip(map(typeof, args), args)) > f(argdict[A], argdict[B]) #etc... > end > > Note that it won't work if any of your A,B,etc are abstract types because > argdict will always end up with concrete types for keys. Additional error > checking possible at the discretion of the developer. > > On Friday, January 8, 2016 at 12:17:47 PM UTC-5, hustf wrote: >> >> The "if"-sentences look kind of non-Julian, and it's very easy to >> introduce bugs that way in my humble experience. Makes for very long code, >> too, generally speaking. Would writing a macro for establishing the >> alternative sequences be shorter codewise and quicker to run? In a way, >> that is what is done implicitly with keyword arguments? I believe e.g. >> @vectorize_2 arg can be used for a roughly similiar purpose. >> >
