Re: [Rd] delayedAssign changing values

2012-04-26 Thread peter dalgaard
On Apr 27, 2012, at 00:10 , ghostwheel wrote: > > Simon Urbanek wrote >> >>> More intuitive would have been the behavior >>> delayedAssign("x", local({y <- 7; y+3}) ) >>> which only changes x. >> >> That is questionable - I think it is more logical for both environments to >> be the same as d

Re: [Rd] delayedAssign changing values

2012-04-26 Thread ghostwheel
Simon Urbanek wrote > >> More intuitive would have been the behavior >> delayedAssign("x", local({y <- 7; y+3}) ) >> which only changes x. > > That is questionable - I think it is more logical for both environments to > be the same as default. Just think if it -- the point here is to access > l

Re: [Rd] delayedAssign changing values

2012-04-26 Thread Simon Urbanek
On Apr 26, 2012, at 11:59 AM, ghostwheel wrote: > It is really strange that the delayedAssign is evaluated in the environment > it is called from, Not quite, it is evaluated in the environment you specify - and you have control over both environments ... see ?delayedAssign > and thus can hav

Re: [Rd] delayedAssign changing values

2012-04-26 Thread ghostwheel
It is really strange that the delayedAssign is evaluated in the environment it is called from, and thus can have side effects. so x=2 y=3 delayedAssign("x", {y <- 7; y+3}) gives > x [1] 10 > y [1] 7 Both x and y changed. More intuitive would have been the behavior x=2 y=3 delayedAssign("x", loca

Re: [Rd] delayedAssign changing values

2012-04-26 Thread Simon Urbanek
On Apr 25, 2012, at 5:18 PM, McGehee, Robert wrote: > I'm not sure if this is a known peculiarity or a bug, but I stumbled across > what I think is very odd behavior from delayedAssign. In the below example x > switches values the first two times it is evaluated. > >> delayedAssign("x", {x <-

Re: [Rd] delayedAssign changing values

2012-04-26 Thread McGehee, Robert
.@r-project.org [mailto:r-devel-boun...@r-project.org] On Behalf Of McGehee, Robert Sent: Wednesday, April 25, 2012 5:19 PM To: r-devel@r-project.org Subject: [Rd] delayedAssign changing values I'm not sure if this is a known peculiarity or a bug, but I stumbled across what I think is

[Rd] delayedAssign changing values

2012-04-25 Thread McGehee, Robert
I'm not sure if this is a known peculiarity or a bug, but I stumbled across what I think is very odd behavior from delayedAssign. In the below example x switches values the first two times it is evaluated. > delayedAssign("x", {x <- 2; x+3}) > x==x [1] FALSE > delayedAssign("x", {x <- 2; x+3})

Re: [Rd] delayedAssign

2007-09-27 Thread Gabor Grothendieck
You or Peter stated that promises are internal so clearly they should be evaluated going in or out of lists. Otherwise you get the current situation. If you had just wasted as much time as I have trying to debug a program with promises you would immediately understand why it was necessary to be a

Re: [Rd] delayedAssign

2007-09-27 Thread Luke Tierney
On Thu, 27 Sep 2007, Gabor Grothendieck wrote: > Thanks for the explanation. > > For lists either: (a) promises should be evaluated as they > enter the list or (b) promises evaluated as they exit the > list (i.e. as they are compared, inspected, etc.). What makes you conclude that this is what "s

Re: [Rd] delayedAssign

2007-09-27 Thread Gabor Grothendieck
Thanks for the explanation. For lists either: (a) promises should be evaluated as they enter the list or (b) promises evaluated as they exit the list (i.e. as they are compared, inspected, etc.). I gather the intent was (a) but it does not happen that way due to a bug in R. Originally I thought

Re: [Rd] delayedAssign

2007-09-27 Thread Luke Tierney
On Wed, 26 Sep 2007, Gabor Grothendieck wrote: > I thought that perhaps the behavior in the previous post, > while inconsistent with the documentation, was not all that > harmful but I think its related to the following which is a potentially > serious bug. The previous discussion already establi

Re: [Rd] delayedAssign

2007-09-26 Thread Gabor Grothendieck
I thought that perhaps the behavior in the previous post, while inconsistent with the documentation, was not all that harmful but I think its related to the following which is a potentially serious bug. z is a list with a single numeric component, as the dput output verifies, yet we cannot compare

Re: [Rd] delayedAssign

2007-09-19 Thread Gabor Grothendieck
Also note that earlier in the same example we have: > msg <- "old" > delayedAssign("x", msg) > msg <- "new!" > x #- new! [1] "new!" > substitute(x) #- msg x > R.version.string # Vista [1] "R version 2.6.0 alpha (2007-09-06 r42791)" That is substitute(x) gives x, not msg. On 9/19/07, Gabor Grothe

Re: [Rd] delayedAssign

2007-09-19 Thread Peter Dalgaard
Gabor Grothendieck wrote: > The last two lines of example(delayedAssign) give this: > > >> e <- (function(x, y = 1, z) environment())(1+2, "y", {cat(" HO! "); pi+2}) >> (le <- as.list(e)) # evaluates the promises >> > $x > > $y > > $z > > > which contrary to the comment appears unevaluat

[Rd] delayedAssign

2007-09-19 Thread Gabor Grothendieck
The last two lines of example(delayedAssign) give this: > e <- (function(x, y = 1, z) environment())(1+2, "y", {cat(" HO! "); pi+2}) > (le <- as.list(e)) # evaluates the promises $x $y $z which contrary to the comment appears unevaluated. Is the comment wrong or is it supposed to return an ev

Re: [Rd] delayedAssign and interrupts

2006-05-21 Thread Duncan Murdoch
On 5/19/2006 10:55 AM, Duncan Murdoch wrote: > On 5/19/2006 10:37 AM, Luke Tierney wrote: >> On Fri, 19 May 2006, Duncan Murdoch wrote: >> >>> On 5/19/2006 9:54 AM, Roger D. Peng wrote: I noticed something recently that I thought was odd: delayedAssign("x", { Sys.sleep(5); 1 })

Re: [Rd] delayedAssign and interrupts

2006-05-19 Thread Roger D. Peng
Luke Tierney wrote: > On Fri, 19 May 2006, Duncan Murdoch wrote: > >> On 5/19/2006 9:54 AM, Roger D. Peng wrote: >>> I noticed something recently that I thought was odd: >>> >>> delayedAssign("x", { Sys.sleep(5); 1 }) >>> x ## Hit Ctrl-C within the first second or 2 >>> >>> gives me: >>> >>> >

Re: [Rd] delayedAssign and interrupts

2006-05-19 Thread Duncan Murdoch
On 5/19/2006 10:37 AM, Luke Tierney wrote: > On Fri, 19 May 2006, Duncan Murdoch wrote: > >> On 5/19/2006 9:54 AM, Roger D. Peng wrote: >>> I noticed something recently that I thought was odd: >>> >>> delayedAssign("x", { Sys.sleep(5); 1 }) >>> x ## Hit Ctrl-C within the first second or 2 >>> >>>

Re: [Rd] delayedAssign and interrupts

2006-05-19 Thread Duncan Murdoch
On 5/19/2006 9:54 AM, Roger D. Peng wrote: > I noticed something recently that I thought was odd: > > delayedAssign("x", { Sys.sleep(5); 1 }) > x ## Hit Ctrl-C within the first second or 2 > > gives me: > > > delayedAssign("x", { Sys.sleep(5); 1 }) > > x ## Hit Ctrl-C within the first second

Re: [Rd] delayedAssign and interrupts

2006-05-19 Thread Luke Tierney
On Fri, 19 May 2006, Duncan Murdoch wrote: > On 5/19/2006 9:54 AM, Roger D. Peng wrote: >> I noticed something recently that I thought was odd: >> >> delayedAssign("x", { Sys.sleep(5); 1 }) >> x ## Hit Ctrl-C within the first second or 2 >> >> gives me: >> >> > delayedAssign("x", { Sys.sleep(5);

Re: [Rd] delayedAssign and interrupts

2006-05-19 Thread Duncan Murdoch
On 5/19/2006 9:54 AM, Roger D. Peng wrote: > I noticed something recently that I thought was odd: > > delayedAssign("x", { Sys.sleep(5); 1 }) > x ## Hit Ctrl-C within the first second or 2 > > gives me: > > > delayedAssign("x", { Sys.sleep(5); 1 }) > > x ## Hit Ctrl-C within the first second

[Rd] delayedAssign and interrupts

2006-05-19 Thread Roger D. Peng
I noticed something recently that I thought was odd: delayedAssign("x", { Sys.sleep(5); 1 }) x ## Hit Ctrl-C within the first second or 2 gives me: > delayedAssign("x", { Sys.sleep(5); 1 }) > x ## Hit Ctrl-C within the first second or two > x Error: recursive default argument reference >