On Fri, Jul 17, 2015 at 5:50 PM, Brandon Taylor <[email protected]> wrote: > Hi, I'm trying to come up with a reasonable syntax for iteratively building > function calls. Here is the best I've got so far. > > using Lazy > using DataFrames > > type Call! > e::Expr > end > > function Call!(c::Call, e::Expr) > c.e.args = [c.e.args, e.args[2:end]] > c > end > > @_ begin > Call(:( DataFrame() )) > Call!(_, :(e( a = 1, b = 2 ))) > Call!(_, :(e( c = 2, e = 3))) > Call!(_, :(e( f = 2, g = 3))) > eval(_.e) > end > > I'm looking for suggestions for cleaner syntax.
I guess the question would be, why would you need this. Building a :call expression is not the only way of programatically constructing the argument for a function call (and argueable the worst because the use of eval). What about sth like (untested) args = Any[] append!(args, [(:a, 1), (:b, 2)]) append!(args, [(:c, 2), (:e, 3)]) append!(args, [(:f, 2), (:g, 2)]) DataFrame(;args...)
