[Rd] Printing of anonymous functions in calls is sub-optimal
Hadley Wickham
h.wickham at gmail.com
Sat Feb 16 16:22:28 CET 2013
> This is a little tricky for the deparser. It sees a call to a function
> which was determined by an expression. Sometimes you want parens, sometimes
> you don't. For example, if getfun(y) returns a function, it's clearer to
> display a call as getfun(y)(x) than (getfun(y))(x).
>
> I'll see if I can work out which kinds of expressions need to be
> parenthesized and implement it in the deparser.
I suspect it's only when you have a function in the quoted call, not a symbol:
# Don't add parens
q1 <- quote(g(f)(x))
is.symbol(q1[[1]])
# Add parents
q2 <- substitute(f(x), list(f = function(x) {x + 1}))
is.function(q2[[1]])
Thanks for thinking about it!
Hadley
--
Chief Scientist, RStudio
http://had.co.nz/
More information about the R-devel
mailing list