Re: [Rd] How to test if an object/argument is parse tree - without evaluating it?

2014-05-02 Thread Henrik Bengtsson
Thank you all for great feedback - very helpful. They view was great half way up the tree, but I'll add this one to It may be possible, but don't do it. Rethink what you're doing. Hadley touches on this in his write up

[Rd] How to test if an object/argument is parse tree - without evaluating it?

2014-05-01 Thread Henrik Bengtsson
This may have been asked before, but is there an elegant way to check whether an variable/argument passed to a function is a parse tree for an (unevaluated) expression or not, *without* evaluating it if not? Currently, I do various rather ad hoc eval()+substitute() tricks for this that most

Re: [Rd] How to test if an object/argument is parse tree - without evaluating it?

2014-05-01 Thread Duncan Murdoch
On 01/05/2014, 4:39 PM, Henrik Bengtsson wrote: This may have been asked before, but is there an elegant way to check whether an variable/argument passed to a function is a parse tree for an (unevaluated) expression or not, *without* evaluating it if not? Parse tree isn't R terminology. Could

Re: [Rd] How to test if an object/argument is parse tree - without evaluating it?

2014-05-01 Thread Kevin Ushey
Henrik, If I understand correctly, you want something along the lines of (following your example): foo - function(expr) { if (!is.language(expr)) substitute(expr) else expr } ## first example expr0 - foo({ x - 1 }) expr1 - foo(expr0)

Re: [Rd] How to test if an object/argument is parse tree - without evaluating it?

2014-05-01 Thread William Dunlap
This may have been asked before, but is there an elegant way to check whether an variable/argument passed to a function is a parse tree for an (unevaluated) expression or not, *without* evaluating it if not? I doubt it. Some packages say that if the argument is a formula then its right hand

Re: [Rd] How to test if an object/argument is parse tree - without evaluating it?

2014-05-01 Thread Hadley Wickham
On Thu, May 1, 2014 at 4:08 PM, Kevin Ushey kevinus...@gmail.com wrote: Henrik, If I understand correctly, you want something along the lines of (following your example): foo - function(expr) { if (!is.language(expr)) substitute(expr) else expr } ## first example

Re: [Rd] How to test if an object/argument is parse tree - without evaluating it?

2014-05-01 Thread peter dalgaard
My take would be that this is barking up the wrong tree. If you want to pass expressions in a way that a function can recognize, use formulas or expression objects. One problem is that pretty much every unevaluated argument is a parse tree. The only other thing it can be is a constant object,