Re: [R] Understanding eval

2007-12-23 Thread Charilaos Skiadas
On Dec 23, 2007, at 9:21 AM, Duncan Murdoch wrote: > On 23/12/2007 9:15 AM, Duncan Murdoch wrote: >> On 22/12/2007 5:45 PM, Charilaos Skiadas wrote: >>> On Dec 22, 2007, at 4:44 PM, Duncan Murdoch wrote: > 5) eval then creates the environment where this evaluation > will take place. It

Re: [R] Understanding eval

2007-12-23 Thread Duncan Murdoch
On 23/12/2007 9:15 AM, Duncan Murdoch wrote: > On 22/12/2007 5:45 PM, Charilaos Skiadas wrote: >> On Dec 22, 2007, at 4:44 PM, Duncan Murdoch wrote: 5) eval then creates the environment where this evaluation will take place. It does that by creating an environment containing the

Re: [R] Understanding eval

2007-12-23 Thread Duncan Murdoch
On 22/12/2007 5:45 PM, Charilaos Skiadas wrote: > On Dec 22, 2007, at 4:44 PM, Duncan Murdoch wrote: >>> 5) eval then creates the environment where this evaluation will >>> take place. It does that by creating an environment containing >>> the frame "a=5", and with enclosing environment the p

Re: [R] Understanding eval

2007-12-22 Thread Charilaos Skiadas
That's a very good idea. I'll have to see if and how it applies to the more general case I'm dealing with. ( Essentially I am trying to create "tkcbind" and "tkrbind" kind of functions, that group together tcltk widgets under a new frame they create, and the frame has to be created before

Re: [R] Understanding eval

2007-12-22 Thread Gabor Grothendieck
Duncan has already pointed out that consideration of promises is what is missing in the description but in addition the way lm and other functions in R get around it is to use match.call like this: bar2 <- function(er) { mc <- match.call() mc[[1]] <- as.name("foo") names(mc

Re: [R] Understanding eval

2007-12-22 Thread Charilaos Skiadas
On Dec 22, 2007, at 4:44 PM, Duncan Murdoch wrote: >> 5) eval then creates the environment where this evaluation will >> take place. It does that by creating an environment containing >> the frame "a=5", and with enclosing environment the parent frame >> of foo, which is bar's environment.

Re: [R] Understanding eval

2007-12-22 Thread Duncan Murdoch
On 22/12/2007 3:30 PM, Charilaos Skiadas wrote: > After many hours of debugging code, I came to the conclusion that I > have a fundamental misunderstanding regarding eval, and hope that > someone here can explain to me, why the following code acts as it does: > > foo <- function(expr) { >e

[R] Understanding eval

2007-12-22 Thread Charilaos Skiadas
After many hours of debugging code, I came to the conclusion that I have a fundamental misunderstanding regarding eval, and hope that someone here can explain to me, why the following code acts as it does: foo <- function(expr) { eval(substitute(expr), envir=list(a=5), enclos=parent.frame()