Re: [Rd] Printing of anonymous functions in calls is sub-optimal

2013-02-17 Thread Duncan Murdoch
On 13-02-16 6:29 PM, Duncan Murdoch wrote: On 13-02-16 10:22 AM, Hadley Wickham wrote: 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

Re: [Rd] Printing of anonymous functions in calls is sub-optimal

2013-02-16 Thread William Dunlap
vel-boun...@r-project.org] On > Behalf > Of Hadley Wickham > Sent: Saturday, February 16, 2013 7:22 AM > To: Duncan Murdoch > Cc: r-devel@r-project.org > Subject: Re: [Rd] Printing of anonymous functions in calls is sub-optimal > > > This is a little tricky for the depa

Re: [Rd] Printing of anonymous functions in calls is sub-optimal

2013-02-16 Thread Duncan Murdoch
On 13-02-16 10:22 AM, Hadley Wickham wrote: 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)

Re: [Rd] Printing of anonymous functions in calls is sub-optimal

2013-02-16 Thread Duncan Murdoch
On 13-02-16 10:19 AM, Hadley Wickham wrote: On Sat, Feb 16, 2013 at 12:24 AM, Bert Gunter wrote: As there has been no response to this ... Why not simply: g <- substitute(f(x),list(f=function(x){x+1})) ## with curly braces g function (x) { x + 1 }(x) x <- 2 eval(g) [1] 3 Thomas Lum

Re: [Rd] Printing of anonymous functions in calls is sub-optimal

2013-02-16 Thread Hadley Wickham
> 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

Re: [Rd] Printing of anonymous functions in calls is sub-optimal

2013-02-16 Thread Hadley Wickham
On Sat, Feb 16, 2013 at 12:24 AM, Bert Gunter wrote: > As there has been no response to this ... > > Why not simply: > >> g <- substitute(f(x),list(f=function(x){x+1})) ## with curly braces >> g > function (x) > { > x + 1 > }(x) >> x <- 2 >> eval(g) > [1] 3 Thomas Lumley sent me a similar sug

Re: [Rd] Printing of anonymous functions in calls is sub-optimal

2013-02-16 Thread Duncan Murdoch
On 13-02-15 10:45 AM, Hadley Wickham wrote: e.g. substitute(f(x), list(f = function(x) x + 1)) # function (x) # x + 1(x) An extra pair of parentheses would really help: (function(x) x + 1)(x) (Better indenting etc would be nice, but not necessary for correct understand of the code) This is

Re: [Rd] Printing of anonymous functions in calls is sub-optimal

2013-02-16 Thread Bert Gunter
As there has been no response to this ... Why not simply: > g <- substitute(f(x),list(f=function(x){x+1})) ## with curly braces > g function (x) { x + 1 }(x) > x <- 2 > eval(g) [1] 3 Cheers, Bert On Fri, Feb 15, 2013 at 7:45 AM, Hadley Wickham wrote: > e.g. > > substitute(f(x), list(f = f

[Rd] Printing of anonymous functions in calls is sub-optimal

2013-02-15 Thread Hadley Wickham
e.g. substitute(f(x), list(f = function(x) x + 1)) # function (x) # x + 1(x) An extra pair of parentheses would really help: (function(x) x + 1)(x) (Better indenting etc would be nice, but not necessary for correct understand of the code) Hadley -- Chief Scientist, RStudio http://had.co.nz/